【发布时间】:2019-06-06 14:35:17
【问题描述】:
我需要在 Wordpress 网站上进行一次 301 重定向而不是两次
我需要https://www.example.com/sports/test/index.php -> https://www.example.com/sports/test
我有两次 301 重定向 https://www.example.com/sports/test/index.php -> https://www.example.com/sports/test/ -> https://www.example.com/sports/test
我在 Wordpress 上有一个结构为 http://www.example.com 的网站,然后我购买了 ssl-sertificate 和我现在的结构 https://www.example.com
设置:
1) 固定链接 -> 自定义结构 https://www.example.com/%category%/%postname%/
2) 类别前缀 -> 。 (只是点)
3) .htacess(使用 Wordpress 的原始 URL 规则)
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#use many recomendation
#-------like this
#RewriteCond %{HTTP_HOST} ^example\.com [NC]
#RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
#-------end like this
#-------like this
#RewriteEngine on
#RewriteCond %{HTTP_HOST} !^www\. [OR]
#RewriteCond %{HTTPS} off
#RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
#RewriteRule ^ https://www.%1%{REQUEST_URI} [NE,L,R=301]
#-------end like this
RewriteRule ^index\.php$ - [L] #remove index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
一切正常,但有两次 301 重定向或多次循环重定向,我需要在 WP 网站上重定向一次。谢谢你帮助我)
【问题讨论】:
标签: wordpress .htaccess redirect url-rewriting url-redirection