Forum Moderators: phranque
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-m-(.*).html$ index.php?manufacturers_id=$2&%{QUERY_STRING}
ErrorDocument 403 /errorpages/403.html
ErrorDocument 401 /errorpages/401.html
ErrorDocument 500 /errorpages/500.html
ErrorDocument 400 /errorpages/400.html
ErrorDocument 404 site_map.php
RewriteCond %{HTTP_HOST}!^www\.mysite\.com [NC]
RewriteCond %{HTTP_HOST}!^$
RewriteRule ^(.*) [mysite.com...] [L,R=301]
But I want to change it so that it will redirect non-www urls to www urls. I've mucked about with it a few times, and managed to cause my site to *Poof* disappear. After each of these experiences, I vow to leave it alone-but a few months later I get reckless again. like now. Any help?
This code works fine-for rewriting my urls AFTER the domain. But I want the added functionality of redirecting non-www requests to www to avoid the canonical issues I've read so much about.
I've tried to modify the code myself to accomplish this using various snippets, but my experiments alwayr resulted in the aforementioned "Poof".
Again, what specifically happens when you run this code? What do you see in the browser, and what do you see in your server access log and your server error log?
I assume you are aware that the code you posted contains the domain redirect code -- The wording of your first post says, "here's what I've got, but when I *add* a domain redirect..." But the domain redirect is already in there, and should already be working for all requests, actually.
Jim
The "poof" I was referring to was my previous attempts to merge this-
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ [yourdomain.com...] [L,R=301]
-into what I originally posted-which is the code that is currently in my htaccess file at the url I pmed you. Thanks for your time on this, and apologies for my ignorance.
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\.mysite\.com
RewriteRule (.*) [mysite.com...] [R=301,L]
Apologies for the bother.