Forum Moderators: phranque
I was wondering if it is possible to redirect an url with the trailing slash and without it to the same destination which is a simple script using mod_alias.
Like:
[somehost.com...] => [otherhost.com...]
[somehost.com...] => [otherhost.com...]
Is there any (performance, security) disadvantages using mod_rewrite?
thanks in advance,
tw
Check out the "Canonical Hostnames" section of [httpd.apache.org ] -- all you need to do is be able to distinguish a "directory" request from a "page" request. So for example if all pages end with some extension like .html, .jsp, .whatever you could rewrite any requests that didn't have this pattern by tacking a slash onto the end, like:
RewriteCond!^/.*\..*$
RewriteRule ^(.*)$ $1/
The condition says "if the URL doesn't have a dot somewhere in the middle" and the rule says "rewrite the entire URL, the part in the parens, to one that has a slash on the end. If you can distinguish between regular URLs and ones that are probably directories more simply, then you can just use a rule. You could probably do this without the condition but I would have to test that, e.g.
RewriteRule!^(/.*)\..*$ $1/
I am sure someone can tell us if this latter rule would work.