【问题标题】:url rewrite working on local but not on serverurl重写在本地但不在服务器上工作
【发布时间】:2015-06-19 05:04:29
【问题描述】:
RewriteEngine on
Options +FollowSymlinks    

RewriteRule ^index\.html$  index.php [L]

RewriteRule ^gallery/([0-9]+)/([a-zA-Z0-9-_]+)/$   gallery.php?pid=$1&urln=$2 [L]

在 localhost pid=$1 上工作得非常好,但在服务器 (OVH) 上我得到一个空值。该网址工作正常,我到达了gallery.php

感谢您的帮助!

【问题讨论】:

    标签: php html .htaccess


    【解决方案1】:

    您的服务器很可能启用了MultiViews 选项。 Apache's content negotiation module 使用选项 MultiViews,它运行 before mod_rewrite 并使 Apache 服务器匹配文件的扩展名。所以/file 可以在 URL 中,但它会服务于/file.php

    试试这个:

    Options +FollowSymlinks -MultiViews   
    RewriteEngine on
    
    RewriteRule ^index\.html$ index.php [L,NC]
    
    RewriteRule ^gallery/([0-9]+)/([\w-]+)/$ gallery.php?pid=$1&urln=$2 [L,QSA]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-11-08
      • 2012-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-10
      • 1970-01-01
      相关资源
      最近更新 更多