gpt4 book ai didi

.htaccess - 301 仅在特定 url 上重定向,同时使用 seo 友好重写

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:46:38 25 4
gpt4 key购买 nike

我有一个从许多地方链接到的新网站,但站点地图的结构已更改。我需要将一些旧网址重定向到相关的新网址。

该站点还需要保持其 seo 友好的 url 书写。

我的 .htaccess 中有这个:

<IfModule mod_rewrite.c>

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f

RewriteCond %{REQUEST_URI} !^/(csr|quality|schools|project_management|third_sector|nhs|about)$


RewriteRule ^(.*)$ index.php/$1 [L]

RewriteRule ^(csr|quality|schools|project_management|third_sector|nhs|about)$ /about-us [L,R=301]

</IfModule>

转到/about 会重定向到/about-us(很棒),转到/quality 也会重定向到/about-us(这是正确的)。但是,转到/nhs 或/schools(例如)会出现 404。这是为什么?

我们将不胜感激。

[编辑]

删除了 [L],它开始工作了。谢谢

最佳答案

我认为这可能是因为你的 RewriteRule ^(.*)$ index.php/$1 [L] 有一个 [L] 标志(这意味着最后一个。)。

如果满足第一条规则的条件 RewriteRule ^(.*)$ index.php/$1 [L] Apache 将停止执行其他规则。

尝试删除 [L]

关于.htaccess - 301 仅在特定 url 上重定向,同时使用 seo 友好重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9821930/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com