我的htaccess文件中很少有规则不起作用

时间:2014-01-26 10:14:43

标签: apache .htaccess mod-rewrite

我在使用htaccess时遇到了一些问题。下面是我正在使用的htaccess文件。 301重定向工作正常,但书籍的重定向根本不起作用。

文件^books.php /books/ [R=301,L]底部的另一条规则也有效。我只是想知道其他规则有什么问题。

网站是www.gatecounsellor.com

http://www.gatecounsellor.com/books.php根据规则重定向,但不是http://www.gatecounsellor.com/books/aerospace-engineering-ae/

RewriteOptions inherit
Options +FollowSymlinks
Options -Indexes

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^gatecounsellor\.com$ [NC]
RewriteRule ^(.*)$ http://www.gatecounsellor.com/$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^books/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$     /books/display_book_detail.php?branch=$1&subject=$2&title=$3&isbn_13=$4 [NC,L]    # Handle   product requests
RewriteRule ^books/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ /books/display_subject_books.php?branch=$1&subject=$2 [NC,L]    # Handle product requests
RewriteRule ^books/([A-Za-z0-9-]+)/?$ /books/display_branch_subjects.php?branch=$1   [NC,L]    # Handle product requests

RewriteRule ^books.php /books/ [R=301,L]

AddDefaultCharset UTF-8

任何线索在其他规则中可能出现什么问题?

由于

1 个答案:

答案 0 :(得分:0)

这可能是由于启用MultiViews

将此行放在.htaccess:

之上
Options -MultiViews

更新:在/books/.htaccess中移动这两条规则:

Options +FollowSymlinks -Indexes -MultiViews

RewriteEngine On
RewriteBase /books/

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ display_book_detail.php?branch=$1&subject=$2&title=$3&isbn_13=$4 [NC,L]

RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ display_subject_books.php?branch=$1&subject=$2 [NC,L]

RewriteRule ^([A-Za-z0-9-]+)/?$ display_branch_subjects.php?branch=$1 [NC,L]