[英]creating multiple .htaccess redirects
I currently have a website that is redirecting from - 我目前有一个网站从-重定向
#-- Redirect http://www.mywebsite.com/en/index.php ---> http://www.mywebsite.com/
#Redirects
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/en/index.php$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST} [R=301,L]
I need to add another condition for it to redirect from mywebsite.com ---> http://www.mywebsite.com/ 我需要为其添加其他条件以从mywebsite.com重定向---> http://www.mywebsite.com/
Basically i need to add a statement to redirect non www users to force them into wwww. 基本上,我需要添加一条语句来重定向非www用户,以迫使他们进入wwww。
How can i do this without both conditions and rules messing each other up? 如何在不使条件和规则相互混淆的情况下做到这一点?
Any help is appreciated 任何帮助表示赞赏
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mywebsite\.com
RewriteRule ^(.*)$ http://www.mywebsite.com$1 [L]
RewriteCond %{REQUEST_URI} ^/en/index.php$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST} [R=301,L]
It is possible not to mention mywebsite.com at all, just to check the starting www and use backreference for the domain (did not check the rule). 可能根本不提及mywebsite.com,仅检查起始www并对该域使用反向引用(不检查规则)。
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.(.*)$
RewriteRule ^(.*)$ http://www.%1$1 [L]
RewriteCond %{REQUEST_URI} ^/en/index.php$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST} [R=301,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.