301重定向删除第一个目录
301 Redirect Remove first directory
我有几个 url 我想从 url 中删除整个目录部分。 htaccess 301 重定向是什么?有人可以帮忙吗
例如
https://example.com/first-lastname-word1-word2/biography/firstnamelastname
https://example.com/first-lastname-word1-word2/activity/firstnamelastname
https://example.com/first-lastname-word1-word2/announcements/firstnamelastname
https://example.com/first-lastname-word1-word2/wall/firstnamelastname
成为https://example.com/activity/firstnamelastname
https://example.com/biography/firstnamelastname等等等等
使用 mod_rewrite
保留此规则 第一条规则 就在 RewriteEngine
行下方:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(memorial-photos|videos|images|category)/ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^[^/]+/([^/]+/[^.]+)$ / [L,NE,R=301]
我有几个 url 我想从 url 中删除整个目录部分。 htaccess 301 重定向是什么?有人可以帮忙吗
例如
https://example.com/first-lastname-word1-word2/biography/firstnamelastname
https://example.com/first-lastname-word1-word2/activity/firstnamelastname
https://example.com/first-lastname-word1-word2/announcements/firstnamelastname
https://example.com/first-lastname-word1-word2/wall/firstnamelastname
成为https://example.com/activity/firstnamelastname https://example.com/biography/firstnamelastname等等等等
使用 mod_rewrite
保留此规则 第一条规则 就在 RewriteEngine
行下方:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(memorial-photos|videos|images|category)/ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^[^/]+/([^/]+/[^.]+)$ / [L,NE,R=301]