我有几个由wordpress / php生成的网址
> http://mydomain.com/news-2/newsarticle
> http://mydomain.com/products/category-2
> http://mydomain.com/products/category/products-2
如何重写/重定向任何带-2的URL到没有?结果应该是
> http://mydomain.com/news/newsarticle
> http://mydomain.com/products/category
> http://mydomain.com/products/category/products
这就是我到目前为止所拥有的
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$- [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
谢谢
最佳答案 添加这个给你htaccess:
RewriteRule ^(.*)-2(.*)$/$1$2 [NC,L,R=301]