将标准url重定向到SEO url


PHP Redirect standard URLs to SEO URLs

我目前使用以下重写规则:
RewriteRule ^books/([bc])/([0-9]+)/(.*)/page([0-9]+) books.php?type=$1&id=$2&title=$3&page=$4 [L]
RewriteRule ^books/([bc])/([0-9]+)(.*) books.php?type=$1&id=$2&title=$3 [L]
RewriteRule ^books/(.*) books.php?type=$1 [L]
RewriteRule ^books books.php [L]

我想添加的是,无论是使用htaccess还是PHP,都是从标准URL格式重定向到SEO URL格式。例如:
books.php?b=1 => books/b/1/book-title
books.php?c=1 => books/c/1/category-title

如果这可以使用htaccess完成,那就好了,我不需要绝对的标题,我用PHP处理标题(重定向到正确的URL,以防输入的标题是不正确的)。

谢谢。

看我的答案在这里:我的。htaccess重定向失败

你可以这样重写它(省略标题-你需要php):

RewriteEngine On
RewriteCond %{REQUEST_URI}  ^/books'.php$
RewriteCond %{QUERY_STRING} ^([a-z])=([a-zA-Z0-9_-]+)$
RewriteRule ^(.*)$ http://www.domain.com/%1/%2? [R=302,L]