For a marketing reason, my client needs a standalone HTML Page as the "temporary homepage"
What I would like to do is redirect the homepage to a page OUTSIDE of the WordPress ecosystem - I guess this is done using HTACCESS rules...
Can I even do this without breaking WordPress?
Thanks
For a marketing reason, my client needs a standalone HTML Page as the "temporary homepage"
What I would like to do is redirect the homepage to a page OUTSIDE of the WordPress ecosystem - I guess this is done using HTACCESS rules...
Can I even do this without breaking WordPress?
Thanks
Share Improve this question asked May 13, 2020 at 4:19 HenryHenry 9831 gold badge8 silver badges31 bronze badges 1- 1 If you just add index.html to the root of your WordPress installation that should become the homepage. – Jacob Peattie Commented May 13, 2020 at 6:10
2 Answers
Reset to default 1As @JacobPeattie suggested in comments:
If you just add
index.html
to the root of your WordPress installation that should become the homepage.
This does, however, require that the DirectoryIndex
is set appropriately. For example:
DirectoryIndex index.html
The DirectoryIndex
is the document that Apache tries to serve when you request a directory. In this case, the document root. Specifying a relative URL-path will look for that file relative to the directory being requested.
Or, to have multiple directory index documents (that are tried in turn):
DirectoryIndex index.html index.php
(index.php
would ordinarily be required for WordPress.)
You can change index.html
to anything you like.
You can also specify a file in a specific location elsewhere on the filesystem (providing it is publicly accessible). For example:
DirectoryIndex /path/to/alternative/homepage.php
But this will mean that if you request /path/to/any-directory/
then it will also serve /path/to/alternative/homepage.php
(via an internal subrequest).
The default WordPress front-controller (directives in .htaccess
) don't do anything when you request the homepage (or any directory for that matter). It relies on mod_dir (ie. DirectoryIndex
) to make the internal subrequest for index.php
. Only when you request /<something>
might the request be manually rewritten to index.php
.
Alternately, you can use mod_rewrite, before the WordPress front-controller to internally rewrite the request for the homepage (/
) to your alternative homepage.
For example:
# Internal rewrite to alternative homepage
RewriteRule ^$ /path/to/alternative/homepage.php [L]
# BEGIN WordPress
# : (WordPress front-controller goes here)
If you did literally want to "redirect" to a temporary homepage then you just need to add the R
flag to the above directive. (Although the internal rewrite/subrequest, as mention above, would be preferable in most scenarios.)
For example:
# External "redirect" to alternative homepage
RewriteRule ^$ /path/to/alternative/homepage.php [R,L]
# BEGIN WordPress
# : (WordPress front-controller goes here)
Note that this is a 302 (temporary) redirect.
If you want to redirect the one page to another page then it is possible with the .htaccess
file, add the below rule in the .htaccess
:
Redirect 301 https://example1/ https://example2/
Don't forget to change the example URLs.