I'm trying to alter my htaccess file to redirect, but it's not working and I'm not sure why. The old urls are now giving 404s if that's important.
Old structure: https://www.example.com/category/tag/id/slug
New structure: https://www.example.com/article/slug
I want to capture the slug and put it in the new structure. My htaccess file looks like this:
<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>
I was thinking I had the last RewriteRule correct there, but perhaps I'm missing something?
Solved.
Correct syntax was:
RewriteRule ^.*/.*/.*/(.*) /article/$1 [R=301,NC,L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.