【发布时间】:2018-01-18 05:49:58
【问题描述】:
我在我的 .htaccess 文件中添加了一些新规则,在添加这些规则之后,我的网站现在重定向了 2 次,有没有一种方法可以让我保留我的规则,并且我的网站只会重定向一次,这是写入的规则我的 .htaccess 文件
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]
# 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
我已经检查了来自以下site 的重定向。
我不确定我做错了什么。
【问题讨论】:
-
我很确定
RewriteBase /blog/你不需要RewriteRule . /blog/index.php除非它是/blog/blog/index.php你应该能够做到RewriteRule . /index.php因为这就是RewriteBase的意义所在 -
先生,我需要它,因为当我删除 /index.php 时,它会将我重定向到无处并让我回到同一页面
-
你使用的是哪个框架..?
-
先生,我正在开发 wordpress
-
@RaghbendraNayakSystematix - 显然这是 wordpress。
标签: php apache .htaccess redirect mod-rewrite