/ Published in: Apache
Please, be careful with trailing slash rewrite as post requests without a trailing slash will be ignored.
Be sure to test if you plan on using that one.
Not compatible with Drupal.
Be sure to test if you plan on using that one.
Not compatible with Drupal.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
## no-www redirect RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] ## www redirect RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] ## multiple domain redirect RewriteCond %{HTTP_HOST} !^example\.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [R=301,L] ## trailing slash ## BE EXTRA CAREFUL WITH THIS ONE! ## POST REQUESTS WITHOUT TRAILING SLASH ## WILL BE IGNORED! RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ http://www.example.com/$1/ [L,R=301]