【发布时间】:2013-10-02 16:35:24
【问题描述】:
我正在尝试使用 Apache 的 mod_rewrite 模块将来自 Yii 应用程序(始终包含 index.php 作为路由器/引导程序)动态生成的 url 通过 .htaccess 转换为静态 url,可通过 Web 浏览器进行浏览。
示例:localhost/projectname/index.php/commentfeed.xml是动态生成的页面,但我希望它能够通过localhost/projectname/commentfeed.xml访问
我正在运行的 Apache 版本是:Apache/2.4.4 (Win32) OpenSSL/1.0.1e PHP/5.5.0 通过 XAMPP 用于我的开发平台。 mod_rewrite 模块存在并加载在 Apache 的 httpd.conf 文件中。
我在localhost/projectname/中的.htaccess如下:
#Turning on the rewrite engine is necessary for the following rules and features.
#FollowSymLinks must be enabled for this to work.
<IfModule mod_rewrite.so>
Options +FollowSymlinks
RewriteEngine On
#Unless an explicit file or directory exists,
#redirect all request to Yii entry script.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
现在,当我尝试通过没有 index.php (localhost/projectname/commentfeed.xml) 的浏览器访问 commentfeed.xml 时,我收到 404 错误 - 找不到对象!。
我查看了以下指南和 SO 问题:URL Rewriting Guide、mod_rewrite documentation 和 SO: Tips for debugging .htaccess rewrite rules,但它们都没有明确说明我在寻找什么。此外,我的 apache 错误日志没有报告任何关于 .htaccess 文件的信息。对于正确使用的任何帮助或指导将不胜感激。
【问题讨论】:
标签: apache .htaccess mod-rewrite yii