我目前有这些页面:
http://example.com/category/page/123/test-test
http://example.com/category/page/2563/test2-test
http://example.com/category/page/2853/test2-test
我想将301重定向到这个:
http://example.com/page/123/test-test
http://example.com/page/2563/test2-test
http://example.com/page/2853/test2-test
如何在不逐个处理的情况下重定向我的所有页面?
我也有以下几行:
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
#this is where I plan to put my rewrite text
RewriteRule ^(system) - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]
答案 0 :(得分:0)
你应该为此目的使用mod重写
这样的事情应该这样做
RewriteEngine on
RewriteRule ^(system) - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule ^/category/page/(\d+)/(.*)$ /page/$1/$2 [R=301,NC]
RewriteRule .* index.php/$0 [PT,L]
您可以查看mod rewrite
的文档