我很难获得两条重写规则。现在这些链接确实有效:
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]
答案 0 :(得分: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]
答案 1 :(得分: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
答案 2 :(得分:0)
您应该像这段代码一样编写rewrite_rules:
RewriteRule (.*)/(.*)/(.*)/(.*)$ index.php?var1=$1&var2=$2&var3=$3&var4=$4 [L]
您的编写代码与任何内容都匹配。