Reputation: 327
I need to redirect all pages for a domain to a subpage called 'emergency'.
However ignore two specific pages - the 'emergency' page itself and another page called 'system'.
I currently have:
AcceptPathInfo On
Options -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^111\.111\.111\.111
RewriteCond %{REQUEST_URI} !^/(emergency|system)/?$ [NC]
RewriteRule ^ /emergency? [L,R=301]
RewriteCond $1 !^(index\.php|assets|robots\.txt|cgi-bin|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^/index.php
RewriteCond $1 !.(css|js|png|jpe?g|gif|ico)$ [NC]
RewriteRule ^(.*)$ /index.php?/$1 [L]
This does not work.
I have already looked at, but could not get anything working either:
Any help would be appreciated!
Thanks!
Upvotes: 1
Views: 481
Reputation: 785186
There is a leading slash after ^
Try this rule:
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^111\.111\.111\.111
RewriteCond %{REQUEST_URI} !^/(emergency|system)/?$ [NC]
RewriteRule ^ /emergency? [L,R=301]
Your full and corrected .htaccess
AcceptPathInfo On
Options -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^111\.111\.111\.111
RewriteCond %{REQUEST_URI} !^/(index\.php|emergency|system)/?$ [NC]
RewriteRule ^.+$ /emergency? [L,R=301]
RewriteCond $1 !^(index\.php|assets|robots\.txt|cgi-bin|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^/index.php
RewriteCond $1 !.(css|js|png|jpe?g|gif|ico)$ [NC]
RewriteRule ^(.*)$ /index.php?/$1 [L]
Upvotes: 1