【问题标题】:.htaccess rewrite url - from ~username - osx apache.htaccess 重写 url - 来自 ~username - osx apache
【发布时间】:2013-04-15 00:01:04
【问题描述】:

您好,我在 mac 上使用 apache,我已启用 php。我正在尝试使用 .htacess 重写我的网址。

http://localhost/~username/project/test  to http://localhost/~username/project/index.php?url=test
But received 404 error - on retrieving url - http://localhost/~username/project/test .

But - this - http://localhost/~username/project/index.php?url=test - Php is working fine.

我的 .htacess 文件包含以下五行:


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

我可以在 php 信息中的已加载模块中看到 mod_rewrite。我如何调试它以找出是否正在调用 .htaccess 。

我的 .htaccess 文件的路径是 - ~username/Sites/project/.htaccess。

【问题讨论】:

    标签: macos .htaccess mod-rewrite apache2


    【解决方案1】:

    来自Troubleshooting

    确保您没有对相关文件范围有效的 AllowOverride None。对此的一个很好的测试是将垃圾放入您的 .htaccess 文件并重新加载页面。如果未生成服务器错误,则几乎可以肯定 AllowOverride None 有效。

    或者反过来,在htaccess中添加一些垃圾,即

    Foobar
    

    并重新加载页面。如果您收到一些 500 服务器错误消息,则 htaccess (AllowOveride) 已启用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-13
      • 2012-02-07
      • 1970-01-01
      相关资源
      最近更新 更多