문제

I'm trying to add a rule into my .htaccess file so that if I am changing my website at all, it will redirect the user to an "under construction" page when they try to access my site.

I'm using:

# SITE UNDER CONSTRUCTION REDIRECT
Redirect 302 / http://redsquirrelsoftware.co.uk/construction.html

But this then sends me to http://redsquirrelsoftware.co.uk/construction.htmlconstruction.htmlconstruction.htmlconstruction.htmlconstruction.htmlconstruction.htmlconstruction.htmlconstruction.htmlconstruction.htmlconstruction.htmlconstruction.html and I obviously get a 404 error.

How do I stop the recursive tail on the web address?

도움이 되었습니까?

해결책

Redirect is a mod_alias directive that can't be mixed with mod_rewrite directives, so to prevent the loop you should use only mod_rewrite directives like this:

Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !construction\.html   [NC]
RewriteCond %{REQUEST_URI} !folder_to_exclude    [NC]
RewriteRule .*           /construction.html      [R=301,L]

This answer assumes /construction.html page is in the same domain. If it isn't, replace:

RewriteRule .*             /construction.html         [R=301,L]

with

RewriteRule .*   http://new_domain/construction.html  [R=301,L]

다른 팁

Try to use a precondition:

RewriteCond %{REQUEST_URI} !^/construction.html
Redirect 302 / http://redsquirrelsoftware.co.uk/construction.html
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top