簡體   English   中英

正則表達式重定向301文件夾以及Wordpress中該文件夾的所有帖子

[英]Regex to redirect 301 a folder and all posts from that folder in Wordpress

剛剛將我的網站從www.example.com/blog移到了www.example.com

我需要向我的.htaccess添加301重定向,以將使用www.example.com/blog/...網址調用的所有內容重定向,例如將www.example.com/blog/category重定向至www.example.com/categorywww.example.com/blog/post-titlewww.example.com/post-title

我已經重定向了該文件夾,但是它似乎不起作用。 你能幫助我嗎?

這是文件夾301的代碼:

RewriteEngine On
RewriteRule ^blog(/.*)?$ /$1 [L,NC,NE,R=301]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-
RewriteRule ^blog(/.*)?$ /$1 [L,NC,NE,R=301]
RewriteRule ^index\.php$ - [L]
RewriteRule . /index.php [L]

在您的網站根目錄.htaccess中,頂部具有以下規則:

RewriteEngine On

RewriteRule ^blog(/.*)?$ https://%{HTTP_HOST}/$1 [L,NC,NE,R=301]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM