Simple redirect in .htaccess not working


Hi, I have a line on my .htacess wich works on other webhosting services I tested before, but not working on 000webhost, I know there is a line to add:

RewriteBase /

but still not working, here is my .htacess:

AddDefaultCharset UTF-8

RewriteEngine On
RewriteBase /

RewriteRule ^desktop$ desktop.html[L]

It’s simple, on browser has to redirect to the desktop.html page which is in public_html folder. I also tried to add a slash:

RewriteRule ^desktop$ /desktop.html[L]

The browser return 404 not found.

Any help?


@parazitenew Try this,

RewriteEngine on RewriteOptions inherit RewriteCond %{HTTP_HOST} ^$ [NC] RewriteRule ^(.*)$$1 [R=301,L]

Or Log in to 000webhost Account,
then go to “Settings” – “Redirect” and set up redirect.

Hope this helps you.


Thank you for your help.

The code you written didn’t work, I tried to set a redirection through “Settings”, It worked, the .htaccess was updated automatically to:

Redirect 301 /desktop http://mywebsite/desktop.html

The problem is that the .html is shown on the browser adress bar, my goal by the redirection is to remove the extension page from the browser. Any idea?


Very easy! Just add this code to your .htaccess file!
(You can access it with index and index.html)

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]

#301 from to
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ /$1 [R=301,L]


However, if you add this code, there will be a redirect loop, so before adding this code, make sure to remove the redirect that you created in settings.


I deleted the redirection from settings but it still working, I think there is a cache on the server, may be I have to wait.

@ckhawand I tried your code with /index, it didn’t redirect to my index.html :confused: (404 not found)


Can you tell us your website link?



Okay, try out this code:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.html -f 
RewriteRule ^(.*)$ $1.html


What is the actual link that you are trying to remove the extension on?

#11 (I think)


@ckhawand I can’t try with /desktop because the older redirection is still on, although I removed it from settings. So I tried with /index, still 404 not found, in the console log of chrome, I can see that the browser is looking for and not, that means that the rewrite rule didn’t work.


@parazitenew Create a “desktop” directory and then place your “desktop.html” in it, then rename “desktop.html” to “index.html”.
This solution will solve your issue.
Now you will be able to load ""


Was your issue solved @parazitenew?


@ckhawand sadly not yet. The solution suggested by @akhilkumar332 is a good idea, but I will apply it if any other solution is found.


Actually, what @akhilkumar332 suggested is the best thing to do, because by default NGINX redirects the folder to the index.html file if there is one. His instructions will solve your problem.


Ok, I did the trick. I think this is the only way. Thank you.