I am currently developing a website and have a holding page in a /hold folder. However I have my WordPress installation in the root too.
What I want is that if a user goes to:
www.domain.com
They get forwarded to:
However if someone goes to http://www.domain.com/index.php it loads WordPress instead. That way, I can still work on WordPress by going to /index.php and anyone who visits the site normally see’s the holding page.
I currently have this in my .htaccess:
# Set a default home directory, (this subfolder always loads)
# Replace 'folder' with your subfolder name
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ /hold/ [R=301,L]
</IfModule>
# Always use www in the domain
# Replace 'example.com' with your domain name
RewriteEngine on
#RewriteCond %{HTTP_HOST} ^([a-z.]+)?domain\.com$ [NC]
#RewriteCond %{HTTP_HOST} !^www\. [NC]
#RewriteRule .? http://www.%1domain.com%{REQUEST_URI} [R=301,L]
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
You should be able to do this without resorting to
mod_rewrite. How about:See the
RedirectMatchdocumentation.However you may be better off setting up a second virtualhost, so you can put your entire public site into holding (using something like
RewriteRule ^.*$ /hold/ [R=503,L]to get the 503 HTTP status code) but still use the WordPress admin and site yourself through a different hostname. (I don’t know if WordPress will have problems with doing that; I have a feeling its insistence on knowing the domain it runs under may cause you problems, sadly.)(I suspect you’re running into problems because your first
RewriteRuleassumesRewriteBase /will already have happened, although it’s been a while since I usedRewriteBase, and the documentation isn’t clear on this. For such a simple pair of cases I’d avoidRewriteBasecompletely to avoid confusion.)