Forum Moderators: phranque
[edited by: g1smd at 10:23 pm (utc) on Nov 21, 2012]
[*]Options -Indexes
ErrorDocument 403 /customerrors/403.html
ErrorDocument 401 /customerrors/401.html
ErrorDocument 400 /customerrors/400.html
ErrorDocument 500 /customerrors/500.html
ErrorDocument 404 /customerrors/404.html RewriteEngine On
RewriteBase /
DirectoryIndex index.php
RewriteCond %{http_host} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://example.com/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Options -Indexes
ErrorDocument 403 /customerrors/403.html
ErrorDocument 401 /customerrors/401.html
ErrorDocument 400 /customerrors/400.html
ErrorDocument 500 /customerrors/500.html
ErrorDocument 404 /customerrors/404.html RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L] Add an extra RewriteCond condition in the ruleset that internally rewrites.
This will test that REQUEST_URI is NOT ^/customerrors/
DirectoryIndex index.php
Options -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
ErrorDocument 404 /customerrors/404.html
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.example.com/ [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
## RewriteRule . /index.php [L]
RewriteBase / is the default and not needed to be stated.
RedirectMatch permanent ^/some-old-url$ http://www.example.com/some-new-url RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# redirected url
RedirectMatch Permanent ^/some-old-url$ http://www.example.com/the-new-url
# remove index.php from urls
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php(/[^\ ]*)?\ HTTP/
RewriteRule ^index\.php(/(.*))?$ http://www.example.com/$1 [R=301,L]
# add www if it's missing
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
# wordpress basic
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RedirectMatch Permanent ^/some-old-url$ http\:\/\/www\.example\.com\/the\-new\-url
RewriteRule ^/some-old-url$ http\:\/\/www\.example\.com\/the\-new\-url [R=301,L]
Redirect 301 ^/some-old-url$ http\:\/\/www\.example\.com\/the\-new\-url
RewriteRule ^/some-old-url$ http\:\/\/www\.example\.com\/the\-new\-url [R=301,L] RewriteRule ^some-old-url$ http://www.example.com/the-new-url [R=301,L]
Options -Indexes
Options +FollowSymLinks
Options -MultiViews
RewriteEngine on
RewriteBase / <--- required on this host
# permanently redirected page
RewriteRule ^some-old-url$ http://www.example.com/my-new-url [R=301,L]
# redirect requests containing index.php/ to their NON index.php/ version
rewritecond %{THE_REQUEST} ^[A-Z]+\ /index\.php(/[^\ ]*)?\ HTTP/
rewriterule ^index\.php(/(.*))?$ http://www.example.com$1 [R=301,L]
# add www if it is missing
rewritecond %{HTTP_HOST} !^(www\.example\.com)?$ [NC]
rewriterule (.*) http://www.example.com/$2 [R=301,L] # redirect requests containing index.php/ to their NON index.php/ version
rewritecond %{THE_REQUEST} ^[A-Z]+\ /index\.php(/[^\ ]*)?\ HTTP/
rewriterule ^index\.php(/(.*))?$ http://www.example.com$1 [R=301,L]
example.com/index.php/some-old-url still redirects twice