Php 与.htaccess中URL的起始名称相同的URL重写问题

Php 与.htaccess中URL的起始名称相同的URL重写问题,php,apache,.htaccess,mod-rewrite,url-rewriting,Php,Apache,.htaccess,Mod Rewrite,Url Rewriting,我访问与URL起始名称相同的URL时遇到问题,如下所示: RewriteEngine On # Turn on the rewriting engine RewriteRule ^sections?$ sections.php [NC,L] RewriteRule ^sections/?$ sections.php [NC,L] RewriteRule ^sections/([0-9]+)/([a-zA-Z-.]+)/view?$ view_s

我访问与URL起始名称相同的URL时遇到问题,如下所示:

RewriteEngine On    # Turn on the rewriting engine

RewriteRule    ^sections?$   sections.php   [NC,L]

RewriteRule    ^sections/?$   sections.php    [NC,L]

RewriteRule    ^sections/([0-9]+)/([a-zA-Z-.]+)/view?$   view_sections.php?id=$1&name=$2   [NC,L]

RewriteRule    ^sections/([0-9]+)/([a-zA-Z-.]+)/view/?$   view_sections.php?id=$1&name=$2    [NC,L]
前2条规则有效,但后2条规则无效,它只加载sections.php而不是view sections.php。当我使用Wamp时,它工作,但当我在线上传时,它不工作。这是因为php和apache的版本吗

我的Wamp版本:

Apache版本:2.4.9

PHP版本:5.5.12

托管版本:

Apache版本:Apache/2.2.27

PHP版本:5.6.14

如果问题是版本问题,那么有什么可能的解决方案使其在托管版本中工作?

像这样尝试

Options -MultiViews

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^sections?$ sections.php [NC]
RewriteRule ^sections/?$ sections.php [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^sections/([0-9]+)/([a-zA-Z-.]+)/view?$ view_sections.php?id=$1&name=$2 [QSA,NC]
RewriteRule ^sections/([0-9]+)/([a-zA-Z-.]+)/view/?$ view_sections.php?id=$1&name=$2 [QSA,NC,L]

谢谢你,伙计!成功了!我刚刚在上面插入了这个(选项-多视图)。顺便问一下,你能告诉我那条线的用法吗?hehewell这里解释得很好,如果它对您有效,您可以通过单击答案旁边的右箭头确认这是一个答案。