volume1 Posted September 29, 2015 Share Posted September 29, 2015 I want my shop to appear as www.myshop.com and NOT as http://myshop.com or w.myshop.com, ww.myshop.com etc. I tried to put this on its own in .htaccess: RewriteRule (.*) http://www.myshop.com/$1 [R=301,L] but that didn't work. I couldn't even access my shop anymore. Then I used tho original htaccess which was on my server already and added the same line after </IfDefine>: # $Id$## This is used with Apache WebServers## For this to work, you must include the parameter 'Options' to# the AllowOverride configuration## Example:## <Directory "/usr/local/apache/htdocs"># AllowOverride Options# </Directory>## 'All' with also work. (This configuration is in the# apache/conf/httpd.conf file) # The following makes adjustments to the SSL protocol for Internet# Explorer browsers #<IfModule mod_setenvif.c># <IfDefine SSL># SetEnvIf User-Agent ".*MSIE.*" \# nokeepalive ssl-unclean-shutdown \# downgrade-1.0 force-response-1.0# </IfDefine>RewriteRule (.*) http://www.myshop.com/$1 [R=301,L]#</IfModule> I can now access my shop alright but it still doesn't rewrite properly. Any suggestions? Link to comment Share on other sites More sharing options...
oscMarket Posted September 29, 2015 Share Posted September 29, 2015 Try: RewriteEngine on RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L] Link to comment Share on other sites More sharing options...
volume1 Posted September 29, 2015 Author Share Posted September 29, 2015 Cool, thanks! But now I get http://www.w.myshop.com if I write w.myshop.com Link to comment Share on other sites More sharing options...
MrPhil Posted September 29, 2015 Share Posted September 29, 2015 Of course it's going to do that! w.myshop.com does not begin with www., so www. will be prepended to it. You need to specify all the formats that you want to accept (why?) and then you can add code for each one. What is the point of allowing w. and ww.? Link to comment Share on other sites More sharing options...
volume1 Posted September 30, 2015 Author Share Posted September 30, 2015 Mistyping. I have had visitors that mistyped www but I suppose its not a problem for google as duplicate content or what? Link to comment Share on other sites More sharing options...
Hotclutch Posted September 30, 2015 Share Posted September 30, 2015 Won't be a problem unless you have links to those type of URLs. In webmaster tools you should set your preferred domain, and that should be sufficient to take care of any duplicate content issues. Link to comment Share on other sites More sharing options...
MrPhil Posted September 30, 2015 Share Posted September 30, 2015 If you want to catch w. and ww., probably the simplest way to do it would be to change the code to RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://www.YOUR_DOMAIN/$1 [R=301,L] That, or teach your visitors how to type :). Note that you have to give your domain name instead of using %{HTTP_HOST}, and that it will catch any domain not starting with www. If you need to handle different domains, you can explicitly specify YOUR_DOMAIN in the RewriteCond, instead of (.*). If you want to allow some subdomains, it will have to be done differently. Repeat in a similar manner for the https side. Link to comment Share on other sites More sharing options...
volume1 Posted September 30, 2015 Author Share Posted September 30, 2015 Thanks for all everyone, very helpful ! :) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.