Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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
Apache:澄清文件';s/directory';存在_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Apache:澄清文件';s/directory';存在

Apache:澄清文件';s/directory';存在,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我有一个带有url的网站,它使用mod_rewrite重写文件(都在同一个文件夹中) url是这样的形状:/sales/ 下面是mod_rewrite的翻译: RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^sales/([a-z0-9A-Z\-]+)/?$ /sales/boatlist.php?folder=$1 [NC,L] 因此,服务器上的目标文件是: 不过,这是我

我有一个带有url的网站,它使用
mod_rewrite
重写文件(都在同一个文件夹中)

url是这样的形状:
/sales/

下面是mod_rewrite的翻译:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^sales/([a-z0-9A-Z\-]+)/?$ /sales/boatlist.php?folder=$1 [NC,L]
因此,服务器上的目标文件是:

不过,这是我的问题。

当请求这个确切的类别时(
sales/yachts
),加载的页面是一个apache禁止的回复,并且根本不加载PHP<未调用code>boatlist.php。我由此推断,目录中有一个文件或文件夹(因此通过
RewriteCond
转义
mod_rewrite
)被标记为禁止,
但是,在服务器上不存在具有此名称的文件/文件夹,并且没有其他与mod_重写相关的文件/文件夹(即使有,也不应返回403禁止回复)

我已找到服务器错误日志,其中说明:

AH01630:服务器配置拒绝客户端:/farm/site/public/sales/yachts

很明显,我发现它似乎不适用,因为我的Apache版本是2.4.25(并且已经安装了很长时间),当前的httpd.conf为:

<Directory "/var/www/html">
    Options All
    AllowOverride None
    Require all granted
</Directory>

今天早上,我运行了自动服务器更新软件(仅为服务器更新插件)并重新启动了Apache

Apache没有更新(所以仍然是相同的版本),但是更新了各种插件,在重新启动Apache之后,问题消失了


我仍然不知道是什么原因导致Apache出现这种明显的混乱。

Hi@anubhava。对于
/foo/
,此输出
/bar
(如预期)。所有其他路径与URL的工作方式相同。
mod_rewrite
似乎没有什么大问题,据我所知,这个问题太具体了。编辑:对于完整的url,不符合此规则。啊,是的;重写引擎在httpd.conf中自动打开,因此它不会出现在htaccess中。为了清楚起见,我将添加它。好的,看来它解决了你的问题。。weird@anubhava,谢谢你的关注
<Directory "/var/www/html">
    Options All
    AllowOverride None
    Require all granted
</Directory>
RewriteEngine On
ErrorDocument 404 /index.php?msg=404
ErrorDocument 403 /index.php?msg=403
ErrorDocument 500 /index.php?msg=500
Options -Indexes

#Set asset items to cache for 1 week.
<FilesMatch "\.(gif|jpe?g|png|ico|css|js|swf)$">
     Header set Cache-Control "max-age=1972800, public, must-revalidate"
</FilesMatch>

#force requests to begin with a slash.
RewriteCond  %{REQUEST_URI}  !^$
RewriteCond  %{REQUEST_URI}  !^/
RewriteRule  .*              -    [R=403,L]

#disabled for subdomain
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS} off
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

#if not a file or dir then use as a boat details page variable.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^boats/(\d+)-?([\w-]+)/?$  /sales/boatdetails.php?boatid=$1 [NC,L]

#if not a file or dir then use as a boatlist page variable.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^sales/([a-z0-9A-Z\-]+)/?$ /sales/boatlist.php?folder=$1 [NC,L]

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]

<Files php.ini>
Require all denied
</Files>

<LimitExcept GET POST HEAD>
    deny  from all
</LimitExcept>