Return to Snippet

Revision: 22722
at January 20, 2010 08:28 by shabbar


Updated Code
RewriteEngine on
RewriteBase /

# Rewrite Rule 1: Redirect all direct requests for URLs including the foldername to non-folder URLs at www.
# Note we can't use REQUEST_URI because you get recursion. You only want to redirect the original string.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /blog/.*\ HTTP/
RewriteRule ^blog/(.*)$ http://domain.com/$1 [R=301,L]

# Rewrite Rule 2: Redirect all www to non-www and preserve folder and file path.
RewriteCond %{HTTP_HOST} ^www.^domain\.com [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

# Rewrite Rule 3: Rewrite non-folder URLs to folder filepath.
RewriteCond %{REQUEST_URI} !^/blog/
RewriteRule ^(.*)$ /blog/$1 [L]

Revision: 22721
at January 20, 2010 08:26 by shabbar


Initial Code
RewriteEngine on
RewriteBase /

# Rewrite Rule 1: Redirect all direct requests for URLs including the foldername to non-folder URLs at www.
# Note we can't use REQUEST_URI because you get recursion. You only want to redirect the original string.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /blog/.*\ HTTP/
RewriteRule ^blog/(.*)$ http://thevirtualdesign.com/$1 [R=301,L]

# Rewrite Rule 2: Redirect all www to non-www and preserve folder and file path.
RewriteCond %{HTTP_HOST} ^www.^thevirtualdesign\.com [NC]
RewriteRule ^(.*)$ http://thevirtualdesign.com/$1 [R=301,L]

# Rewrite Rule 3: Rewrite non-folder URLs to folder filepath.
RewriteCond %{REQUEST_URI} !^/blog/
RewriteRule ^(.*)$ /blog/$1 [L]

Initial URL


Initial Description


Initial Title
redirect root to sub directory

Initial Tags


Initial Language
HTML