Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

htaccess


volume1

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...