.htaccess重定向规则不适用于某个特定规则的正斜杠

时间:2011-11-01 16:23:37

标签: regex apache .htaccess mod-rewrite

您是否发现此重写有问题?它似乎永远不会得到匹配。

rewriterule ^content/([^/]+)/$ modules.php?module=$1 [L]

以下是匹配的网址:http://simplenexus.com/content/articles/

以下是目的地:http://simplenexus.com/modules.php?module=articles

其他rewriterule线确实匹配。例如,以下行完美运行:

rewriterule ([^/]*).html$ content.php?pagename=$1 [L]

两个重写规则都在同一个.htaccess文件中,并且彼此相邻。什么是interesitng,匹配似乎是斜杠(/)和除斜杠([^ /] *)之外的任何东西的组的问题。

在同一文件中正常工作的另一条规则是:

rewriterule ^profiles/json/(.+/profile.json)$ http://app.simplenexus.com/profiles/json/$1 [R=302,L]

以下是htaccess文件中的所有内容:

Options +FollowSymlinks
rewriteengine on
rewritecond %{HTTP_HOST} ^www.simplenexus.com$ [OR]
rewritecond %{HTTP_HOST} ^simplenexus.com$
rewriterule ^install\.html$ http://simplenexus.com/redirect.php [R=302,L] #4de6cfc989e1b
rewriterule ^profiles/json/(.+/profile.json)$ http://app.simplenexus.com/profiles/json/$1 [R=302,L]

RewriteRule ^content/([^/]*)/$ http://simplenexus.com/modules.php?module=$1 [L]
#rewriterule ^content/([^/]*)/$ modules.php?module=$1 [L]

rewriterule ([^/]*).html$ content.php?pagename=$1 [L]

#Article Manager
RewriteRule article-archive/([0-9]{4})/([0-9]{1,2})$ modules.php?module=articles&do=article-archive&y=$1&m=$2 [L]
RewriteRule article-tags/([^/]*)$ modules.php?module=articles&do=article-tags&tagname=$1[L]
RewriteRule article/([^/]*)\.html$ modules.php?module=articles&do=article&artname=$1 [L]
RewriteRule article-category/([^/]*)/([0-9])-([0-9])\.html$ modules.php?module=articles&do=article-category&catname=$1&pg=$2&ipp=$3
RewriteRule article-category/([^/]*)\.html$ modules.php?module=articles&do=article-category&catname=$1 [L]
RewriteRule article-search/$ modules.php?module=articles&do=article-search [L]

#<Files *.jad>
##    Header set Content-Disposition attachment
#</Files>

AddType text/vnd.sun.j2me.app-descriptor .jad
AddType application/vnd.rim.cod .cod

感谢您的任何见解。

0 个答案:

没有答案