2014-01-19 33 views
1

我需要通過使用htaccess刪除url的feed。
如何301 example.com/xxx/feed example.com/xxx/在htaccess

我用RewriteRule ^[0-9]{4}/[0-9]{1,2}/[^/]+/feed/?$ /[R,L]

但它不能直接鏈接

http://www.example.com/xxx/feed

向右網址

http://www.example.com/xxx/

我不太瞭解htaccess。

如果你能告訴我怎麼樣或給我一些建議來學習如何做,它真的非常感謝你的幫助。

只需在htaccess中將url:example.com/xxx/feed重定向到example.com/xxx/。

回答

1

簡化您的規則是:

RewriteEngine On 
RewriteRule ^(.+?)/feed/?$ /$1/ [L,R] 

或使用RedirectMatch:(?+)?

RedirectMatch 302 ^/(.+?)/feed/?$ /$1/ 
+0

RedirectMatch 302 ^//飼料/ $/$ 1 /爲我工作?謝謝。祝你有個美好的一天〜 – Sorata

+0

不客氣,很高興它解決了。 – anubhava