我已经写了一条规则.htaccess它根据要求工作得很好现在需求略有变化我很困惑我怎么能通过改变我之前的规则来实现这个目标当用户点击域example.com或www.example.com时,用户应重定向到
此规则现在正在运行,下一个要求是当用户点击域
时OR
他应该重定向到
但是这件事不起作用是我到目前为止所写的规则。
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]
任何人都可以告诉我我做错了什么
答案 0 :(得分:0)
我们目前使用
<IfModule mod_rewrite.c>
# Force https and www
RewriteCond %{SERVER_PORT} !=443
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
# Force www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
# The rest of your rules
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>