Forum Moderators: phranque

Message Too Old, No Replies

.htaccess rewrite, doesn't work without trailing slash

         

StoutFiles

7:21 pm on Aug 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteRule ^category/([^/]+) /category.php?type=$1 [NC]
RewriteRule ^(.*)\/$ $1.php [NC]

I currently have this setup and it works fine.

http://www.example.com/category.php?type=1
becomes
http://www.example.com/category/1

Geat. The problem is when I go to the category page originally I have no variable for type. So for it to work, I have to make my link
http://www.example.com/category/ .

That's ok, I can deal with that. The problem is, the broswer history is not saving the trailing slash after category making the link http://www.example.com/category, which is a broken link. How would I rewrite the link so that the link without a variable in type would work with a slash and with no slash?

[edited by: StoutFiles at 7:27 pm (utc) on Aug. 14, 2008]

StoutFiles

7:35 pm on Aug 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



nevermind, figured it out

g1smd

7:47 pm on Aug 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Post the answer here for the next person with the same question.

Ta!