views:

448

answers:

1

What do I need to do to the following rewrite rule to make it so it works whether or not their is a slash at the end of the URL?

ie. http://mydomain.com/content/featured or http://mydomain.com/content/featured/

RewriteRule ^content/featured/ /content/today.html
+5  A: 

Use the $ to mark the end of the string and the ? to mark the preceding expression to be repeated zero or one times:

RewriteRule ^content/featured/?$ content/today.html

But I recommend you to stick to one notation and correct misspelled:

# remove trailing slashes
RewriteRule (.*)/$ $1 [L,R=301]

# add trailing slashes
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ $0/ [L,R=301]
Gumbo
+1 mostly for the additional info, although I was gonna' give it to you anyway.
Unkwntech