Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么.htaccess会阻止对.php文件的访问_.htaccess_Webserver - Fatal编程技术网

为什么.htaccess会阻止对.php文件的访问

为什么.htaccess会阻止对.php文件的访问,.htaccess,webserver,.htaccess,Webserver,我的web服务器中有一个.htaccess文件,它从我的URL中删除index.php。 当我想访问位于Web服务器子目录中的.php文件时,就会出现问题 我的htacess文件如下所示: # Turn on URL rewriting RewriteEngine On # Installation directory RewriteBase / # Protect application and system files from being viewed RewriteRule

我的web服务器中有一个.htaccess文件,它从我的URL中删除index.php。 当我想访问位于Web服务器子目录中的.php文件时,就会出现问题

我的htacess文件如下所示:

# Turn on URL rewriting

RewriteEngine On

# Installation directory

RewriteBase /


# Protect application and system files from being viewed

RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]


# Allow any files or directories that exist to be displayed directly

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL

RewriteRule .* index.php/$0 [PT]
现在如果我想访问这样的.php文件:

# Turn on URL rewriting

RewriteEngine On

# Installation directory

RewriteBase /


# Protect application and system files from being viewed

RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]


# Allow any files or directories that exist to be displayed directly

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL

RewriteRule .* index.php/$0 [PT]

服务器返回了一个500错误

我该怎么做才能解决这个问题

谢谢。

也许你可以试试:

RewriteRule ^(.*).(css|js|xml|ico|png|gif|jpe?g)$ $1.$2 [L]
RewriteRule ^.*$ index.php [L,QSA]
然后在PHP usig中获取请求的URL

$url = $_SERVER["REQUEST_URI"];

查看服务器错误日志。它会告诉您它不喜欢.htaccess的哪一部分。很可能是
tiny\u mce\u gzip.php
文件中的一个错误导致了问题-如果删除
.htaccess
文件,您仍然会收到错误吗?我现在通过将的文件权限更改为555来修复它。现在一切都好了。为什么会这样?是的,即使从Web服务器中删除.htaccess,它仍然返回500错误。如果我将tiny_mce_gzip.php更改为只包含echo'a',它仍然不起作用。那么,在将权限更改为555之前,权限在哪里(这有点奇怪,人们通常希望目录上的755也允许所有者对其进行写入)。错误日志将再次告诉您实际的问题。。