Portal Home > Knowledgebase > Articles Database > Mod rewrite problem


Mod rewrite problem




Posted by roughrider, 10-04-2007, 08:36 PM
I have this and it works fine: RewriteRule ^(.*).html$ index.php?tools=hardware&type=$1.php [L] So when someone goes to "mysite.com/industrial.html", they will be redirected to the right page. However, I want to change it to this, and it does not work RewriteRule ^(.*)$ index.php?tools=hardware&type=$1.php [L] So people would only have to go to "mysite.com/industrial"

Posted by david510, 10-05-2007, 01:21 AM
Where have you placed the rewrite rule? Inside web root folder or another folder?

Posted by david510, 10-05-2007, 02:43 AM
You need the following redirection? mysite.com/anything ---> mysite.com/index.php?tools=hardware&type=anything.php

Posted by Indy, 10-05-2007, 04:52 AM
I use this stuff religiously lol. RewriteRule ^forum/(.*)/(.*)/pg(.*)/ viewthread.php?tid=$2&page=$3 [L,NC] That redirects... http://www.somedomain.com/forum/11/23/pg1/index.php to... http://www.somedomain.com/viewthread.php?tid=23&page=1 I really shouldn't call it redirect because it is invisible to the users. Edit: The first (.*) really does nothing. I have this setup to basically build a forum tree.

Posted by roughrider, 10-05-2007, 10:58 AM
Yes, I need this redirection. The .htaccess file is in the root folder.

Posted by david510, 10-05-2007, 11:30 AM
You may try this rule.

Posted by roughrider, 10-05-2007, 07:49 PM
Works perfectly, thank you!



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
RoR (Views: 498)
web site layouts (Views: 539)