1

我很难让两个重写规则起作用。现在这些链接确实有效:

http://domainname.com/blog/something/something/andsomethingelse/
http://domainname.com/blog/
http://domainname.com/leaderboard/

如果我访问 /leaderboard/something,它会显示来自 WordPress 博客的 Not Found 错误页面,忽略排行榜重写规则。

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /leaderboard/index.php [L]
4

3 回答 3

1
Options +FollowSymLinks
RewriteEngine On
RewriteBase /

# Ignore real files/folders
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .? - [L]

RewriteRule ^blog/(.+?)$ /blog/index.php [L] # WP standard syntax
RewriteRule ^leaderboard/(.+?)$ /leaderboard/index.php?var=$1 [L]
于 2013-07-30T19:04:09.213 回答
0

我相信这可能是您正在寻找的。

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^blog/(.+)$ /blog/index.php?path=$1
RewriteRule ^leaderboard/(.+)$ /leaderboard/index.php?path=$1

然后您可以像这样访问页面:

http://domain.com/blog/something/somethingelse
http://domain.com/leaderboard/something/somethingelse

在后台它看起来像这样:

http://domain.com/blog/index.php?path=something/somethingelse
http://domain.com/leaderboard/index.php?path=something/somethingelse
于 2013-07-30T14:55:57.647 回答
0

您应该像这样编写 rewrite_rules 代码:

RewriteRule (.*)/(.*)/(.*)/(.*)$ index.php?var1=$1&var2=$2&var3=$3&var4=$4 [L]

你的编写代码匹配任何东西。

于 2013-07-30T14:57:58.070 回答