Ever wondered if you needed a separate html page on root of your WordPress installation? And it becomes difficult to handle WordPress because it takes you to your root domain if you click on Home link or the logo of your site.
Actually this is easy to set up and has two ways to achieve this.
Option 1 – Define a default document
1 |
DirectoryIndex index.html index.php index.htm default.html default.htm home.html |
The above code will go in your .htaccess file which is located on root of your domain.
The sequence tells Apache to follow which file first, and the rest accordingly. So I set index.html first and it will always be served when the root domain is accessed in the browser. Your WordPress file can remain index.php as it won’t be picked up when accessing the root domain.
Option 2 – Rewrite index file for WordPress
So for any reason if you cannot have the option 1 work for you, you can use a rewrite method in .htaccess file. Before doing that, you have to rename your WordPress’ index.php file to something else. To show an example, I use index_wp.php. Follow the sample code below.
1 2 3 4 5 6 7 8 9 10 11 12 |
# BEGIN WordPress <ifmodule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteRule ^index_wp\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index_wp.php [L] </ifmodule> # END WordPress |
The above code is pretty easy and self explanatory. We are telling WordPress to use index_wp.php as its default root file for all purposes. WordPress will be using index_wp.php for loading its own pages with all the functions.
I hope the above quick tutorial is useful for you. Please feel free to leave your feedback or improvements in the comments section below.