OpenCart .htaccess 301 redirect
Using OpenCart how would I use a 301 redirect to add www.
to the domain
.htaccess
content:
#Options +FollowSymlinks
<IfModule mod_rewrite.c>
RewriteEngine On
#OPENCART REWRITES START
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php
#OPENCART REWRITES END
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.mysite\.com$ [NC]
RewriteRule ^(.*)$ h开发者_如何学JAVAttp://www\.mysite\.com/$1 [R=301,L]
</IfModule>
Note that 302 redirects are working
I think all that you are wanting to do is this inside of your Apache config file.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite\.com
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]
I use like this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite\.net
RewriteRule ^(.*)$ http://www.mysite.net/$1 [R=permanent,L]
Try this code. I am keeping this as standard for non-www to www and force https both. No further change required.
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L,NE]
精彩评论