Redirect does not work

I now use index.php instead of index.html for my site (https://citationstudio2.000webhostapp.com/) so I have set a redirect from index.html in the 000webhost control panel but it does not work. When I type the old address https://citationstudio2.000webhostapp.com/index.html the browser stays at index.html (with a 404 error as index.html is not found) even though my .htaccess file correctly includes the following redirect directive:

# HTID:20437199: DO NOT REMOVE OR MODIFY THIS LINE AND THE LINES BELOW
Redirect 301 /index.html https://citationstudio2.000webhostapp.com/
# DO NOT REMOVE OR MODIFY THIS LINE AND THE LINES ABOVE HTID:20437199:

I have looked everywhere and double-checked everything I could think of. My .htaccess is in the right place (in my public_html folder on 000webhost) and this does not appear to be simply a case of syntax error. The server generates an error when I insert some rubbish in .htaccess (as a test) so the file itself is not ignored but I can’t figure out why the redirect directive is ignored.

I should be very grateful for any comments or suggestions. Thanks in advance.

Maybe I’m being thick but if you are now using index.php in your public_html folder then simply delete the index.html if you’ve not already and the website will automatically load index.php without any additional directives or rulings.

If you’ve done this already and you still want index.html redirected then in a blank index.html file put a meta redirect again not using directives/rulings in .htaccess

<meta http-equiv="refresh" content="0; url=https://citationstudio2.000webhostapp.com/index.php">

You could try a .htaccess rule also if you are facing problems with the server loading .html instead of .php firstly

DirectoryIndex index.php index.html

Only guesswork with that last rule.

Dear Infinity

Many thanks for your prompt response. Yes, the server loads index.php properly, and I had already tried your suggestion of putting a meta redirect in an otherwise blank index.html, but my question is really about why the .htaccess redirect does not work. Actually I can’t get any other .htaccess directive to work, and I am left to wonder if perhaps the AllowOverride directive in the apache configuration files (or some other setting beyond my reach) somehow means that my .htaccess is not enabled in the first place?

I’m really grateful for your input.

I’ve refreshed your panel and fixed any permissions and ran the “fix website tool” on 000webhost also

I’ve tried two test rules and both directives worked fine, it may just be that something was wrong on the server end but seems to be working fine now so I would go ahead and test anything out if you still need to :slight_smile:

Fantastic, I was beginning to despair but it now works. You are a life saver, Infinity! I cannot thank you enough for solving my problem.

1 Like

This topic was automatically closed after 40 hours. New replies are no longer allowed.