Page 1 of 1

mod_rewrite

Posted: Sat Feb 11, 2006 10:07 pm
by Benjamin
Hi I am having trouble figuring out how to set up the htaccess file. This is what I have.

Code: Select all

RewriteEngine on
Options +FollowSymlinks
RewriteBase /projects/cms/

RewriteEngine on
RewriteRule ([^/]+)\.html$   index.php?car=$1
RewriteRule ([^/]+)\.html$   description.php?vehicle=$1
If someone clicks on a link like http://mydomain/car/13.html it is supposed to display a list of all the cars available for the category.

If someone clicks on a link like http://mydomain/vehicle/13.html it is supposed to show the details on that vehicle.

What it is actually doing though is showing the details if you go to the first url though.

Posted: Sat Feb 11, 2006 10:10 pm
by feyd
your regex is passing through.

I think you may need the [L] modifier (last)

Posted: Sat Feb 11, 2006 10:14 pm
by Benjamin
Changed to:

Code: Select all

RewriteEngine on
Options +FollowSymlinks
RewriteBase /projects/cms/

RewriteEngine on
RewriteRule ([^/]+)\.html$   index.php?car=$1 [L]
RewriteRule ([^/]+)\.html$   description.php?vehicle=$1
Thanks feyd, that solved the first problem, however going to:

http://domainname/description/12.html is still getting routed to the index page.

Posted: Sat Feb 11, 2006 10:17 pm
by feyd
your regex needs to be tweaked to understand what to match and what not to.. after you fix that, you can actually lose the [L]

Posted: Sat Feb 11, 2006 10:19 pm
by Benjamin
Can you help me? I have never learned regex.

Posted: Sat Feb 11, 2006 10:22 pm
by Benjamin
Nevermind I figured it out.

Code: Select all

RewriteEngine on
Options +FollowSymlinks
RewriteBase /projects/cms/

RewriteEngine on
RewriteRule ^car/([^/]+)\.html$   index.php?car=$1
RewriteRule ^description/([^/]+)\.html$   description.php?vehicle=$1