我需要一个301重定向在Wordpress网站上不要两次。
我需要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上有一个带有structure http://www.example.com的站点,然后我进行ssl- site和我的结构现在的https://www.example.com。
设置:
1) Permalinks ->定制结构https://www.example.com/%category%/%postname%/
2)类别前缀->。(只是点)
3) .htacess (包含urls的原始规则)
# 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重定向或许多循环重定向,我需要一次重定向的可湿性粉剂网站。谢谢你的帮助)
发布于 2019-06-07 07:23:57
在RewriteEngine On和RewriteBase /之前添加以下行:
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} " /(index\.php|([^?]*)/index\.php)"
RewriteRule ^ https://www.example.com/%2 [R=301,L,NE]
对我来说很好
发布于 2019-06-06 15:19:26
尝试更改permalink结构并重新保存它。
如果.htaccess是wordpress的默认值,那么您应该没有问题。
对于https,我使用这个插件https://it.wordpress.org/plugins/really-simple-ssl/非常简单,而且效率很高。
让我知道
https://stackoverflow.com/questions/56479808
复制相似问题