Reputation: 14747
I can not get this .htaccess work because there is some syntax error that I can't determinate. When I access the website, it prints a Internal Server Error
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^201\.191\.20\.108 #
RewriteCond %{REQUEST_URI} !^/mantenimiento\.php$ #
RewriteRule ^(.*)$ http://example.com/mantenimiento.php [R=307,L] #
By the way, the following error is printed at error_log:
.htaccess: RewriteCond: bad flag delimiters
The idea with this htaccess is redirect all request from example.com
to example.com/mantenimiento.php
in order to simulate a "maintenance mode" in the website
Upvotes: 1
Views: 4212
Reputation: 11809
Here is an example:
Requested URL:
http://example.com
Substitution URL:
http://example.com/mantenimiento.php
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^201\.191\.20\.108
RewriteRule ^(.*)$ http://example.com/mantenimiento.php [R=301,L]
The REQUEST_URI is not needed as there is NONE. To work, the REMOTE_ADDR cannot be the one in the pattern. Can use [307,L] too for a temporary redirection.
Upvotes: 1