Apache 通过htaccess重定向大量页面
我目前拥有以下页面:Apache 通过htaccess重定向大量页面,apache,.htaccess,Apache,.htaccess,我目前拥有以下页面: http://example.com/category/page/123/test-test http://example.com/category/page/2563/test2-test http://example.com/category/page/2853/test2-test 我想将它们重定向到以下位置: http://example.com/page/123/test-test http://example.com/page/2563/test2-test
http://example.com/category/page/123/test-test
http://example.com/category/page/2563/test2-test
http://example.com/category/page/2853/test2-test
我想将它们重定向到以下位置:
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]
为此,您应该使用mod rewrite 像这样的东西应该可以
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]
您可以查看ok的文档,这很奇怪。我相信你的答案会有用的。它不会。从
重写规则中删除L.*index.php/$0[PT,L]
或从我的答案中删除L。添加了以上htaccess的更多内容。从你的答案中去掉L也不起作用。@Thorpe:规则的顺序很重要,所以请看我的编辑;-)那不太顺利。我现在有一个500内部服务器错误