[英]Using custom rewrite rules on Wordpress multisite htaccess file
我正在嘗試在Wordpress多站點設置上的htaccess文件中添加一些自定義重寫規則,但是無論我將它們放在何處都沒有任何效果-我已經在幾個測試網址上檢查了規則本身http://htaccess.madewithlove.be/ ,它們可以按預期工作,但是當放入htaccess文件時,沒有任何反應。 這是因為Wordpress重寫功能的工作方式嗎?
這是我的htaccess文件的內容...
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
# Redirect Test subscription page - needed for subscription ad.
Redirect 301 /subscriptions/test/ /subscriptions/product-category/test/
Redirect 301 /subscriptions/test /subscriptions/product-category/test/
# Redirect the Test 2 stuff as no longer selling them
Redirect 301 /subscriptions/product-category/test2/ /subscriptions/
我要重定向的頁面是…
http://www.example.com/tigers-strengthen-its-position-in-market/testing1/
http://www.example.com/tigers-strengthen-its-position-in-market/testing2/
http://www.example.com/tigers-strengthen-its-position-in-market/testing2/
我想將他們重定向到...
http://www.example.com/news/
我的重定向規則是…
RewriteRule ^tiger-bills-strengthens-position(.*) /news/ [R=301,L]
我設法通過在RewriteCond中使用正則表達式更改來使此工作正常。 工作代碼是…
RewriteCond %{QUERY_STRING} (tigers\-strengthen|testing1|testing2) [NC,OR]
RewriteCond %{REQUEST_URI} (tigers\-strengthen|testing1|testing2) [NC]
RewriteRule ^ http://www.example.com/news/? [L,R=301]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.