部署服务器忽略.htaccess文件

Ami*_*Far 7 php .htaccess mod-rewrite web-deployment

.htaccess在root上的文件如下所示:

RewriteEngine on
RewriteBase /
options +FollowSymLinks
RewriteRule ^en/users/profile/?$ [F,NC]
RewriteRule ^en/users/profile/?([0-9]+)?/?$ en/user/index.php?id=$1
RewriteRule ^en/users/profile/([0-9]+)/photo/? en/user/index.php?pageID=photoEdit&id=$1

RewriteCond %{HTTP_REFERER} !^http://example\.ge/?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://example\.dev/?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://localhost/?.*$ [NC]
RewriteRule \.(gif|jpe?g|png|bmp)$ - [F,NC]
Run Code Online (Sandbox Code Playgroud)

它可以在本地主机上完美重新路由,但在部署服务器上会被忽略!这是 phpinfo(); 服务器!

这是etc文件夹: etc文件夹

MrW*_*ite 1

RewriteRule ^en/users/profile/?$ [F,NC]
Run Code Online (Sandbox Code Playgroud)

不是您的文件被忽略的原因.htaccess(其他答案已经给出了解决方案,关于检查服务器配置中的指令),但您在上述指令中AllowOverride缺少有效的替换。请求/en/users/profile/不会被禁止,并且可能只会导致错误/404。

它需要是这样的:

 RewriteRule ^en/users/profile/?$ - [F,NC]
Run Code Online (Sandbox Code Playgroud)

(只需一个连字符即可替换

RewriteCond %{HTTP_REFERER} !^http://example\.ge/?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://example\.dev/?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://localhost/?.*$ [NC]
RewriteRule \.(gif|jpe?g|png|bmp)$ - [F,NC]
Run Code Online (Sandbox Code Playgroud)

您还应该将“热链接保护”指令(上面)移至路由指令之前。否则,有可能(取决于 URL 格式)在热链接保护能够阻止请求之前路由 URL 。