Forum Moderators: phranque
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.[a-z-]+\.[a-z]{2,6} [NC]
RewriteCond %{HTTP_HOST} ([a-z-]+\.[a-z]{2,6})$ [NC]
RewriteRule ^/(.*)$ http://%1/$1 [R=301,L] http://domain.com/subdiretory/file.html, the browser URL does not change to http://www.domain.com/subdiretory/file.html. [edited by: jdMorgan at 1:00 am (utc) on Feb 12, 2010]
[edit reason] de-linked [/edit]
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_HOST} ^([a-z\-]+\.([a-z]{3,6}|co\.[a-z]{2}))\.?(:[0-9]+)?$ [OR]
RewriteCond %{HTTP_HOST} ^www\.([a-z\-]+\.([a-z]{3,6}|co\.[a-z]{2}))(\.|\.?:[0-9]+)$
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
[edited by: jdMorgan at 2:55 am (utc) on Feb 12, 2010]
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_HOST} ^([a-z\-]+\.([a-z]{3,6}|co\.[a-z]{2}))\.?(:[0-9]+)?$ [OR]
RewriteCond %{HTTP_HOST} ^www\.([a-z\-]+\.([a-z]{3,6}|co\.[a-z]{2}))(\.|\.?(:[0-9]+)$
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L [edited by: jdMorgan at 2:21 pm (utc) on Feb 12, 2010]
[edit reason] de-linked [/edit]
http://example.com/landing-pages/test.html http://www.example.com/landing-pages/test.html http://example.com does redirect to http://www.example.com [edited by: jdMorgan at 2:22 pm (utc) on Feb 12, 2010]
[edit reason] example.com [/edit]
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.[a-z-]+\.[a-z]{2,6} [NC]
RewriteCond %{HTTP_HOST} ([a-z-]+\.[a-z]{2,6})$ [NC]
RewriteRule ^/(.*)$ http://%1/$1 [R=301,L] RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] [edited by: jdMorgan at 2:24 pm (utc) on Feb 12, 2010]
[edit reason] example.com [/edit]
RewriteRule ^/(.*)$ http://%1/$1 [R=301,L] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] [edited by: jdMorgan at 2:24 pm (utc) on Feb 12, 2010]
[edit reason] De-linked. example.com. [/edit]
However, that leaves the question, "If your original code wasn't redirecting to 'www', then what was?" If you've previously tried to do this redirect using your "control panel," I suggest that you remove that setting first, before trying to use .htaccess code to do it.
Options +FollowSymLinks Options +FollowSymLinks -MultiViews