![](/img/trans.png)
[英]non-www to www. redirect AND redirect index.html to index.php
[英]www. rewrite redirect always to www.mydomain.com/index.php
这实际上是一个常见问题,您会为此找到几篇文章(即.htaccess-如何以通用方式强制使用“ www。”? )。 但是我尝试过的所有重定向都不适合我。 万维网。 将被添加,但是所有参数将丢失。
mystore.com/store/view/->重定向到---> www.mystore.com/index.php
mystore.com/product/view/10->重定向到---> www.mystore.com/index.php
这是我尝试过的,应该可以使用的:
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
要么
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
有人能指出我正确的方向吗? 非常感谢。
您可以在根.htaccess中使用此代码:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^index\.php$ - [L,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L,NC]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.