Posts Tagged ‘apache’

apache rewrite with and without ending slash

July 1st, 2012 No comments

Due to implementing one of redirects noticed about existing a lot of duplication entries on redirect config files, only different on which is one of them is followed by ‘/’ and other not.
Apache mod_rewrite use the regular expressions, and it can be filled more accurately.

To prevent duplication entries if you asked redirect with ‘/’ and without it may be used quantifier ‘?’ which mean existing 0 or 1 character after which it followed.

You can find a bit more information about mod_rewrite and regular expressions following to link:
For example, to rewrite and to, you can just do the following:

RewriteRule ^/test/?$ [L,R=301,NC]

instead of the following:

RewriteRule ^/test$ [L,R=301,NC]
RewriteRule ^/test/$ [L,R=301,NC]

Categories: IT Architecture Tags: