我正在尝试更改我的htaccess文件以进行重定向,但它无法正常工作,我不确定为什么。如果重要的话,旧的网址现在会提供404。
Old structure: https://www.example.com/category/tag/id/slug
New structure: https://www.example.com/article/slug
我想捕获该块并将其放入新结构。我的htaccess文件如下所示:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^/.*/.*/.*/(.*)$ /article/%1 [R=301,NC,L]
</IfModule>
我以为我在那里有最后一个RewriteRule,但也许我遗漏了什么?
已解决。
正确的语法是:
RewriteRule ^.*/.*/.*/(.*) /article/$1 [R=301,NC,L]