8

I just installed Wordpress. I have a non Wordpress splash page at [root folder]/index.html. I'd like to keep the splash page up while I work on skinning Wordpress. When I try to access index.php (also in the root folder), it rewrites the url to index.html. I don't see index.html in the url but the splash page is there and I never see Wordpress.

I am able to access the Wordpress admin without issue. Anyone know how I can access Wordpress without making it go live?

6

Either use a plugin (like wp-maintenance-mode) or hardcode your .htaccess file to redirect to the splash page, and allow your own (or your team) IP address to ignore the redirect. Like this:

<IfModule mod_rewrite.c>

RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1
RewriteCond %{REQUEST_URI} !/splashpage.html$ [NC]
RewriteRule .* /maintenance.html [R=302,L]

</IfModule>

Regarding your doubt why index.html gets served from root, it is because it usually takes precedence over index.php. If you wanted to change that, you would have to change the DirectoryIndex.

EDIT: I thought it was obvious, but, for the sake of clarity: 127.0.0.1 should be changed to your public IP address. Also note that 302 is Temporary Redirect, which is what we want.

  • 2
    As I can't comment on other people answers, I would just like to state that I really like @s_ha_dum answer but you should be careful as the Wordpress Codex clearly states: Do not pass a role name to current_user_can(), as this is not guaranteed to work correctly. – Sunyatasattva Nov 29 '12 at 15:25
  • I tried your suggestion and it has not effect. I want index.html to display. I also want to manually access the Wordpress page index.php. But that causes the redirect to index.html. I'm not sure why you are saying "redirect to the splash page". That's exactly what I don't want to happen. Even if I completely clear .htaccess, I still end up with rewrites. – 4thSpace Nov 29 '12 at 15:43
  • @Sunyatasattva, the source code says "@param string $capability Capability or role name.". I wonder when that was added to the Codex, or by whom? – s_ha_dum Nov 29 '12 at 17:13
  • @4thSpace As far as I had understood you wanted to have full access to Wordpress without it going live and redirect users that are not allowed to a custom splash page which you called index.html. When I said "redirect to the splash page" I meant redirect other users to the splash page, not yourself. First of all, for my suggestion to work, have you edited the 127.0.0.1 to your public IP? – Sunyatasattva Nov 29 '12 at 18:08
  • Yes - I did change my public IP. – 4thSpace Nov 29 '12 at 18:15
1

Try this.

function temp_page_redirect() {
    if (!current_user_can('administrator')) {
        wp_safe_redirect('temp.html',307);
    }
}
add_action('template_redirect','temp_page_redirect');

I did not use index.html because because that file name has special significance to the server. The '307' is a status code meaning temporary redirect. I assumed that the 'administrator' role needs access :)

1

I feel the easiest method of achieving this is editing the .htaccess file in the root web directory, and place this at the top:

DirectoryIndex index.html index.php

That swaps the priority order in which Apache chooses which file to use.

  • suits my requirement where i want to add wp pages with existing html site and index page being html. – Sajal Dec 5 '18 at 13:52
0

This works perfectly. Add new plugin folder with this file as index.php.

From the support thread:

"To address the original question, you can turn off canonical redirection by putting this into your plugins directory –"

<?php
/*
Plugin Name: Disable Canonical URL Redirection
Description: Disables the "Canonical URL Redirect" features of WordPress 2.3 and above.
Version: 1.0
Author: Mark Jaquith
Author URI: http://markjaquith.com/
*/ 

remove_filter('template_redirect', 'redirect_canonical'); 

?>

This seemed to help a lot of people there, and might be a proper answer here as well.

  • 1
    Lone link is considered a poor answer (see FAQ) since it is meaningless by itself and target resource is not guaranteed to be alive in the future. Please try to include at least summary of information you are linking to. – Rarst May 26 '13 at 19:21
  • 1. Open your site with an FTP program 2. navigate to /wp-content/plugins/ 3. create a new folder of any name 4. create an index.php and put the PHP code from code comments above (use everything in the code box above) and copy to your new folder 5. visit your wordpress backend and activate this new plugin – Andy Mar 18 at 20:48
0

Try this on your htaccess file:

DirectoryIndex index.html index.php

This code means that apache will look for index.html first, and if it doesn't exist then will look for index.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.