【问题标题】:.htaccess - Mod Rewrite works on xampp but crashes on hosted server.htaccess - Mod Rewrite 在 xampp 上工作,但在托管服务器上崩溃
【发布时间】:2014-02-27 18:24:03
【问题描述】:

我使用 .htaccess 文件将http://localhost/app/search/?s=hello 等网址重定向到http://localhost/app/search.php?s=hello

我在 .htaccess 文件中的代码是:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php !-f

#Search
RewriteRule ^search/([-_0-9a-z]*)$ search.php$1 [L]

RewriteRule ^(.*)/$ $1.php

问题:在我本地机器上的 apache 上一切正常。但是当我将项目放在我的托管服务器上时,我看到以下内容:

找不到

在此找不到请求的 URL /redirect:/search.php.php.php 服务器。

服务器上的设置 für mod-rewrite 也正确。

谁能帮帮我?

感谢您的任何建议。

【问题讨论】:

    标签: apache .htaccess mod-rewrite url-rewriting


    【解决方案1】:

    你只需要这条规则:

    RewriteEngine on
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php !-f
    RewriteRule ^(.+?)/?$ $1.php [L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-16
      • 1970-01-01
      • 1970-01-01
      • 2020-01-04
      • 2015-07-04
      • 1970-01-01
      • 2013-07-04
      • 1970-01-01
      相关资源
      最近更新 更多