Apache 使用错误报告 404(.htaccess 重写)
我有这个网址 http://xxxxxxxxx.com /account/session/login/redirect/%2Fhotel%2Frooms%2Findex%2Fhot_id%2F1 使用 Zend Framework (PHP)。在 .htaccess 的帮助下
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [NC,L]
,我得到了 404 未找到。为了确保它是Apache,我在index.php主文件启动时退出了它,apache仍然报告404。在退出之前没有执行任何php代码。
编辑
我的域的apache domlog显示了这一行
190.78.208.30 - - [25/Aug/2011:17:48:17 -0430] "GET /account/session/login/redirect/Fhotel%2Frooms%2Findex%2Fhot_id%2F1 HTTP/1.1" 404 25821 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0"
,但是error_log中没有关联的行
编辑2
如果有用,我正在运行Apache 2.2.19,PHP 5.3.6 , cpanel 11.30.2, CentOS 5.6
请注意 404 未找到。当我在执行其他任何操作之前退出index.php时,404仍然出现。我可以确定 .htaccess 正在被读取。根据建议,我放置了一个
SetEnv MYENV 1
And 显示在同一域中的 phpinfo() 中。我只是仔细检查了我的 access_log 和 error_log 并保持如上所述。
有什么想法为什么会发生这种情况吗?
I have this url http://xxxxxxxxx.com/account/session/login/redirect/%2Fhotel%2Frooms%2Findex%2Fhot_id%2F1 which uses Zend Framework (PHP). With help of a .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [NC,L]
The thing is i'm getting a 404 Not found. To make sure it was Apache, i exited the index.php main file just when it starts and apache still reports 404. No code of php gets to be executed before that exit.
EDIT
The apache domlog for my domain shows this line
190.78.208.30 - - [25/Aug/2011:17:48:17 -0430] "GET /account/session/login/redirect/Fhotel%2Frooms%2Findex%2Fhot_id%2F1 HTTP/1.1" 404 25821 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0"
But there are no lines associated in the error_log
EDIT 2
If useful i'm running Apache 2.2.19, PHP 5.3.6, cpanel 11.30.2, CentOS 5.6
Please notice the 404 not found. When i exit the index.php before executing anything else the 404 still comes up. I can be sure the .htaccess is being read. Following a recommendation i put a
SetEnv MYENV 1
And is showing up in a phpinfo() in the same domain. I just double checked my access_log and error_log and remain like described above.
Any ideas why this is happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确定 Apache 正在读取您的 .htaccess 文件吗?
确保作者:
您有权覆盖网站目录中的值。要实现此功能,您的 Apache 配置文件中应该包含类似以下内容:
<目录/var/www/html>
将 /var/www/html 替换为您的网站公共目录的路径
Apache 有权读取您的 .htaccess 文件。
这样 Apache 就可以读取并应用 .htaccess 文件中的配置。
要测试它,请在 .htaccess 文件中设置一个环境变量:
然后使用 index.php 文件中的 phpinfo() 函数并搜索环境变量。如果 phpinfo() 输出中不存在环境变量,则意味着 Apache 不会解析 .htaccess 文件。
Are you sure your .htaccess file is being read by Apache?
Make sure that By:
You have permissions to override values in your website directory. to have this you should have something like this in your Apache configuration file:
<Directory /var/www/html>
</Directory>
replace /var/www/html with the path to your website public directory
Apache has permissions to read your .htaccess file.
This way Apache could read and apply configurations in your .htaccess file.
To test it, set an environment variable in your .htaccess file:
and then use the phpinfo() function in your index.php file and search for the environment variable. If the environment variable is not present in your phpinfo() output, it means the .htaccess file is not parsed by Apache.