Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help removing WWW with htaccess


sefu

Recommended Posts

Hi,

I want to use a 301 redirect for my non www to my WWW

e.g yourdomain.com to www.yourdomain.com

 

Below is what my htaccess looks like after I have tried inserting a mod rewrite rule (see lasts lines of code) but when I type in domain.com it directs me to www.domain.com/default.php/

I imagine this has something to do with the SEF commands?

 

Can someone help me get it to do what I would like to do

 

 

# $Id: .htaccess,v 1.3 2003/06/12 10:53:20 hpdl Exp $
#
# 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>
</IfModule>

# If Search Engine Friendly URLs do not work, try enabling the
# following Apache configuration parameter
#
# AcceptPathInfo On

# Fix certain PHP values
# (commented out by default to prevent errors occuring on certain
# servers)
#
#<IfModule mod_php4.c>
#  php_value session.use_trans_sid 0
#  php_value register_globals 1
#</IfModule>

# Ultimate SEO URLs BEGIN
Options +FollowSymLinks
RewriteEngine On 
RewriteBase /

RewriteRule ^/?$ default.php
RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-c-(.*).html$ default.php?cPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-m-([0-9]+).html$ default.php?manufacturers_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pi-([0-9]+).html$ popup_image.php?pID=$2&%{QUERY_STRING}
RewriteRule ^(.*)-t-([0-9]+).html$ articles.php?tPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-a-([0-9]+).html$ article_info.php?articles_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pr-([0-9]+).html$ product_reviews.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pri-([0-9]+).html$ product_reviews_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-i-([0-9]+).html$ information.php?info_id=$2&%{QUERY_STRING}
# Ultimate SEO URLs END

DirectoryIndex default.php
ErrorDocument 400 /http_error.php?error_id=400
ErrorDocument 401 /http_error.php?error_id=401
ErrorDocument 403 /http_error.php?error_id=403
ErrorDocument 404 /http_error.php?error_id=404
ErrorDocument 405 /http_error.php?error_id=405
ErrorDocument 408 /http_error.php?error_id=408
ErrorDocument 415 /http_error.php?error_id=415
ErrorDocument 500 /http_error.php?error_id=500
ErrorDocument 501 /http_error.php?error_id=501
ErrorDocument 502 /http_error.php?error_id=502
ErrorDocument 503 /http_error.php?error_id=503
ErrorDocument 505 /http_error.php?error_id=505
ErrorDocument 504 /http_error.php?error_id=504

Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^domain.com [NC] 
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

Link to comment
Share on other sites

Oh, you mean to get rid of the default part. Try this

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /default\.php\ HTTP/ 
RewriteRule ^index\.php$ http://www.yourdomain.com/ [R=301,L]

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Sorry I'm a newb to this, so I use what you have instead of this?

And this will direct me from domain.com to www.domain.com?

 

Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^domain.com [NC] 
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...