With the latest open cart the .htaccess has the following code
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]
I am trying to work out how to use the Rewrite function to direct www to non www version of the URL.
I have searched the forum and realised people have already brought this up, but I am not to sure how to add it in while leaving the code currently in the .htaccess file.
Any help would be great.
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]
I am trying to work out how to use the Rewrite function to direct www to non www version of the URL.
I have searched the forum and realised people have already brought this up, but I am not to sure how to add it in while leaving the code currently in the .htaccess file.
Any help would be great.
Could you not change your config files to include the "www"?
mine looks like this. redirects all traffic to domain.com just incase someone puts in http://www.domain.com" onclick="window.open(this.href);return false;
oh yeah and I just noticed I also have a rule in there to exclude the robots.txt from rewriting.
Code: Select all
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC]
RewriteRule ^robots.txt$ $0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]
OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter
Xsecrets, does your redirect work with paypal ipn? I've had a few people using redirects for www to non-www or vice versa but it breaks the IPN callback. It looks like you are using a correct 301 (which does support POST var redirection) so I think it should be ok. But I was curious if you know for sure.
didn't even think about it, but I've been using the redirect since I put up my store, and I haven't had any problems with paypal payments. they go through and get set as complete, so I'm guessing the callback is working fine.Qphoria wrote:Xsecrets, does your redirect work with paypal ipn? I've had a few people using redirects for www to non-www or vice versa but it breaks the IPN callback. It looks like you are using a correct 301 (which does support POST var redirection) so I think it should be ok. But I was curious if you know for sure.
OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter
Xsecrets thanks for posting the code.
I am looking to rewrite non www to www.
how exactly would I edit the code you posted?
Options +FollowSymlinks
I am looking to rewrite non www to www.
how exactly would I edit the code you posted?
Options +FollowSymlinks
Code: Select all
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC]
RewriteRule ^robots.txt$ $0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]
Thanks i have been looking for this.
I had a few problems with it at the begining, when i went to www.domain.com through firefox it didnt redirect but did show the site but using IE it just gave an error page. It didnt work until i moved the added code to the bottom of the .htaccess file, i don't know if that made the difference but this is the way mine is now
Cheers again!!!
I had a few problems with it at the begining, when i went to www.domain.com through firefox it didnt redirect but did show the site but using IE it just gave an error page. It didnt work until i moved the added code to the bottom of the .htaccess file, i don't know if that made the difference but this is the way mine is now
Code: Select all
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC]
RewriteRule ^robots.txt$ $0 [L]
This don't seem to work with the .htaccess file in OpenCart 1.5.1. I can't get it to work.
I want to go from non www, to always have www in front of my domain name. Can't anybody help with an updated code?
Also, at my domain, I can write anything instead of www, and my site will stille be shown. Let's say 'blahblah.domain.dk' or '12341243.domain.dk' - they will both show the content of www.domain.dk. How can I via .htaccess re-direct to www.domain.dk?
Thanks.
I want to go from non www, to always have www in front of my domain name. Can't anybody help with an updated code?
Also, at my domain, I can write anything instead of www, and my site will stille be shown. Let's say 'blahblah.domain.dk' or '12341243.domain.dk' - they will both show the content of www.domain.dk. How can I via .htaccess re-direct to www.domain.dk?
Thanks.
i want no www.
the problem is if someone types in www.heartcaptions.com/ocstore the add to cart buttons dont work on the featured area
the problem is if someone types in www.heartcaptions.com/ocstore the add to cart buttons dont work on the featured area
hi, i have used this www to non www redirect provided by xsecrets for ages now...but it seems there is a problem with it.
When i visit http://www.example.com
it redirects to http://example.com successfully
but when i visit http://www.example.com/examplecatergory
it redirects to http://example.com/index.php?_route_=examplecatergory
I have tried placing the 3 lines of code bofore and after the orignal code but this index.php?_route_= keeps appearing, it seems since people ave linked in to our website using www. links google has started to index some of our pages with the index.php?_route_= inlclued in url
please advise on how to use this code correctly. i am running on 1.5.1 and will paste my htaccess below -
When i visit http://www.example.com
it redirects to http://example.com successfully
but when i visit http://www.example.com/examplecatergory
it redirects to http://example.com/index.php?_route_=examplecatergory
I have tried placing the 3 lines of code bofore and after the orignal code but this index.php?_route_= keeps appearing, it seems since people ave linked in to our website using www. links google has started to index some of our pages with the index.php?_route_= inlclued in url
please advise on how to use this code correctly. i am running on 1.5.1 and will paste my htaccess below -
Code: Select all
SetEnv PHPRC "/home/folder/public_html"
DirectoryIndex index.php
Options +FollowSymlinks
#-Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,NC]
RewriteRule ^robots.txt$ $0 [L]
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L,QSA]
<Files 403.shtml>
order allow,deny
allow from all
</Files>
<FilesMatch "\.(tpl|ini)">
Order deny,allow
Deny from all
</FilesMatch>
# Turn on Expires and set default to 0
ExpiresActive On
ExpiresDefault A0
# Set up caching on media files for 1 week
<FilesMatch "\.(gif|jpg|jpeg|png)$">
ExpiresDefault A604800
Header append Cache-Control "public"
</FilesMatch>
# Set up 1 week caching on javascript and CSS
<FilesMatch "\.(js|css)$">
ExpiresDefault A604800
Header append Cache-Control "proxy-revalidate"
SetOutputFilter DEFLATE
</FilesMatch>
# Force no caching for dynamic files
<FilesMatch "\.(php)$">
ExpiresActive Off
Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
</FilesMatch>
Who is online
Users browsing this forum: No registered users and 80 guests