Deployment Server Ignores .htaccess File
RewriteRule ^en/users/profile/?$ [F,NC]
Not the cause of why your .htaccess
file is being ignored (the other answers have already given solutions for that, with regards to checking the AllowOverride
directive in the server config), but you are missing a valid substitution in the above directive. A request for /en/users/profile/
will not be forbidden and will likely just result in an error/404.
It would need to be something like:
RewriteRule ^en/users/profile/?$ - [F,NC]
(Just a single hyphen for the substitution.)
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]
You should also move your "hotlink protection" directives (above) to before your routing directives. Otherwise, it's possible (depending on the URL format) that the URL is routed before the hotlink protection is able to block the request.
You probably don't have .htaccess
files enabled on the server. Have a look at the AllowOverride directive. You can add something like this to the <Directory>
block for your <VirtualHost>
's document root:
AllowOverride all
Edit your virtual host:
1. Login to your server.
2. cd /etc/apache2/sites-available/
3. You can edit your default or web1 or ... virtual-host- .conf -file. Type nano web1.conf (...) and edit your file.
<VirtualHost *:80>
ServerName yoururl.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/web1/htdocs/
<Directory /var/www/web1/htdocs/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
4. Stop your Apache2 and restart it - /etc/init.d/apache2 stop and /etc/init.d/apache2 start.
5. Upload your .htaccess into your root directory and test it.
If you using Cloudflare , then there is a option in the settings " Always use HTTPS " in the SSL settings . You can also use Forwarding URL action :
http://yoururl.fqdn/*
redirected with a 301 response code to
https://www.yoururl.fqdn/$1
链接地址: http://www.djcxy.com/p/96394.html
下一篇: 部署服务器忽略.htaccess文件