1

I'm busy building a Wordpress website for a client. I've developed the site off-line and would now like to upload it to the live server to show the client what I've done so far. I want to keep the "Under Construction" html page I've create as the default when browsing to the site but if you type in www.sitename.com/index.php I want the actual site to be displayed.

I don't want to use an "under construction" plugin as I don't want the user to have to enter any form of username or password to gain access to the site.

I have tried: DirectoryIndex index.htm but as soon as I browse to index.php it flips me back to the index.htm page.

I've had a look here: Make index.html default, but allow index.php to be visited if typed in but unless I'm missing it, there's no real conclusion.

My development machine runs Windows 8 with XAMPP.

4
  • Why don't you put your preview in a directory? Commented May 18, 2013 at 12:45
  • 1
    The question you linked to seems to solve it (it's the order they're placed, just read the answer). Which part there did not work for you? Commented May 18, 2013 at 12:46
  • @BenjaminGruenbaum, I tried the accepted answer but all that happens is when I request index.php I simply get flipped back to index.html Commented May 18, 2013 at 18:33
  • @kingkero, I want to be able to just remove the html file when the site is ready to go live and not have to redirect or move the site afterwards. Commented May 18, 2013 at 18:34

1 Answer 1

1

Use this in your .htaccess file to redirect the user to index.html when he types the domain name, if he especially types index.php, he will be able to get on that page

RewriteRule ^$ index.html [R=301,L]
Sign up to request clarification or add additional context in comments.

11 Comments

Thanks Mr Alien. I tried adding the line you suggested but I'm still getting the same result. I've never worked with .htaccess files before so I'm not too sure I'm doing it right. Here's what the index.php file looks like: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress I've tried replacing the first RewiteRule with your suggestion, I've tried putting it before the Wordpress section, and also on it's own.
@robhob You need to place that line in your .htaccess file
If I use your code: RewriteRule ^$ index.html [R=301,L] index.php loads automatically and if I then type index.html I get the html page. The problem is, I need it to work the other way around - I need it to default to the html page and only go to the php when it is explicitly entered.
@robhob Do your htaccess contains some rules like directory index?
All I have in the .htaccess file is your one line of code: RewriteRule ^$ index.html [R=301,L] Am I right in assuming that I don't need to restart Apache every time I edit this file?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.