Wordpress RewriteRule适用于永久链接,但不适用于主页(Wordpress RewriteRule works on permalinks but not homepage)

编程入门 行业动态 更新时间:2024-10-19 06:16:21
Wordpress RewriteRule适用于永久链接,但不适用于主页(Wordpress RewriteRule works on permalinks but not homepage)

我的网站上有标准的wordpress重写规则:

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>

该站点曾经位于子目录(mysite.com/1/)中,现在是root用户,我想确保对子目录的任何请求都重定向到root。 上面的规则对于包含永久链接的页面(我假设因为RewriteBase)这样做,例如mysite.com/1/contact被重定向到mysite.com/contact,但不是主页,所以mysite.com/1/不是重定向到mysite.com。

任何人都可以提供解决方案将子目录中的主页请求重定向到root吗?

I have the standard wordpress rewrite rules on my site:

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>

The site used to be in a subdirectory (mysite.com/1/), and is now in root, and I want to make sure that any requests for the subdirectory are redirected to root. The rules above do this for pages with permalinks (I assume because of the RewriteBase), e.g. mysite.com/1/contact is redirected to mysite.com/contact, but not for the homepage, so mysite.com/1/ is NOT redirected to mysite.com.

Can anyone provide a solution to redirect requests for the homepage in the subdirectory to root?

最满意答案

我找到了解决方案。 我在原规则下添加了这条规则:

Redirect /1 http://mysite.com

I found a solution. I added this rule under the original rules:

Redirect /1 http://mysite.com

更多推荐

本文发布于:2023-04-29 02:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1334518.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:适用于   但不   链接   主页   Wordpress

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!