网址没有正确重定向?

时间:2015-08-04 10:44:05

标签: php .htaccess

我创建了一些页面,但问题是url没有重定向到我想要的文件。我已经创建了一些标签并在标签中提及。现在当我点击任何标签时它没有重定向到tag.php,它链接到main.php。 为什么会这样,我不明白。

这是我的.htaccess文件

AddDefaultCharset utf-8
Options +FollowSymlinks -Indexes
RewriteEngine on 
RewriteRule ^authors/([^/]*)\.html$ /quotes/main.php?authchar=$1 [QSA,L]
RewriteRule ^authors/([^/]*)/([^/]*)\.html$ /quotes/author.php? authchar=$1&authorname=$2 [QSA,L]
RewriteRule ^([^/]*)/([^/]*)\.html$ /quotes/quotes.php?authchar=$1&authorname=$2&authorquote=$3 [QSA,L]
RewriteRule ^authors/([^/]*)/([^/]*)/([^/]*)\.html$ /quotes/tag.php?authchar=$1&authorname=$2&authorquote=$3&tag=$4 [QSA,L]   

1 个答案:

答案 0 :(得分:0)

您可以在/quotes/.htaccess中使用这些规则:

AddDefaultCharset utf-8
Options +FollowSymlinks -Indexes
RewriteEngine on 
RewriteBase /quotes/

# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

RewriteRule ^authors/([^/]*)\.html$ main.php?authchar=$1 [QSA,L]
RewriteRule ^authors/([^/]*)/([^/]*)\.html$ author.php?authchar=$1&authorname=$2 [QSA,L]
RewriteRule ^([^/]*)/([^/]*)\.html$ quotes.php?authchar=$1&authorname=$2&authorquote=$3 [QSA,L]
RewriteRule ^authors/([^/]*)/([^/]*)/([^/]*)\.html$ tag.php?authchar=$1&authorname=$2&authorquote=$3&tag=$4 [QSA,L]