mod_Rewrite 的问题

发布于 2024-08-28 05:29:05 字数 1088 浏览 5 评论 0原文

最初我有以下 .htaccess 文件:

php_value display_errors 1
php_value error_reporting 7

AddDefaultCharset utf-8

Options -Indexes
<Files ~ ".*\.(info|tpl)$">
    Order allow,deny
    Deny from all
</Files>

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php/$1 [L,QSA]

这触发了 500 内部服务器错误,因此我将前两行移至 php.ini 文件。

之后,错误消失,但重定向不起作用,它只是重定向到空页面,错误日志显示:也找不到文件,另一个日志显示:

PHP Warning:  Unknown: open_basedir restriction in effect. File() is not within the allowed path(s): (/home/:/usr/lib/php:/usr/local/lib/php:/tmp/:/usr/local/:/usr/bin) in Unknown on line 0

我尝试在 RewriteLog 中写入,再次触发 500 服务器错误 有

一点帮助吗?预先感谢

cPanel 11.24.5-STABLE (Build: 38506)
Apache version 2.2.15 (Unix)
MySQL version 5.0.85-community
PHP version 5.2.9
Operating system Linux

Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_fcgid/2.3.5

Originally I had following .htaccess file:

php_value display_errors 1
php_value error_reporting 7

AddDefaultCharset utf-8

Options -Indexes
<Files ~ ".*\.(info|tpl)$">
    Order allow,deny
    Deny from all
</Files>

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php/$1 [L,QSA]

Which triggered 500 internal server error, so I moved first two lines to the php.ini file.

after that, error disappeared, but redirect is not working, it simply redirects to the empty page, error log shows: file not found also, another log shows:

PHP Warning:  Unknown: open_basedir restriction in effect. File() is not within the allowed path(s): (/home/:/usr/lib/php:/usr/local/lib/php:/tmp/:/usr/local/:/usr/bin) in Unknown on line 0

I tried to write in RewriteLog which triggered 500 server error again

A little help? Thank you in advance

P.S.

cPanel 11.24.5-STABLE (Build: 38506)
Apache version 2.2.15 (Unix)
MySQL version 5.0.85-community
PHP version 5.2.9
Operating system Linux

Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_fcgid/2.3.5

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

初雪 2024-09-04 05:29:05

看起来 PHP 正在尝试打开具有空路径的文件,因此您尝试访问的 PHP 脚本中显然存在一些错误。只需检查访问日志,了解您在哪个 URL 上收到此错误,然后尝试修复 PHP 脚本。

It looks like PHP is trying to open file with empty path, so there is clearly some error in the PHP script you're trying to access. Just check the access log on which URL did you get this error and try to fix the PHP script.

不一样的天空 2024-09-04 05:29:05

正如您的 reg-ex 建议

<Files ~ ".*\.(info|tpl)$">

您只允许访问 .info 和 .tpl 文件。我这里有什么问题吗?

编辑:当意识到我这边的错误时发表评论。

As your reg-ex suggests

<Files ~ ".*\.(info|tpl)$">

you are allowing only .info and .tpl files to be accessed. Am i getting something wrong here?

Edit: Made comments when realised the error on my side.

太阳男子 2024-09-04 05:29:05

您应该查看 apache 日志 - 错误将在那里,您将知道之后要修复什么。

You should look into the apache log - the error will be there and you will know what to fix afterward.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文