Redirection using .htaccess not possible here?

My hosting account username is: epiz_29972096
The website managed under that account is: moongazer.epizy.com

(Thank you to those who responded to a minor issue that I experienced yesterday that was entirely due to an error on my part and has now been resolved.)

First, I’d like to say that although I’m not new to using web-hosting, I’m a newbie here, so I have much to learn and I’m hoping this is the place to do it. And if I get things wrong out of ignorance, I’m happy to be corrected.

My website is still under construction and I have been experimenting. I have just now tried to redirect a webpage that is hosted here to another site by placing a .htaccess file in the relevant folder with the redirection in it. I know the syntax is correct because I have successfully used the same technique elsewhere in the past, but it is not working here.

I’m wondering if that is either not allowed or is failing because it is being interfered with by the aes.js code that is injected into my website, which I read about just today.

The folder structure of my website is arranged as follows:
htdocs
|–mywebsite
|–foldera
|–folderb
|–folderc

The page I am trying to redirect is the index page in folder /htdocs/mywebsite/folderb, and I placed the .htaccess file in that folder. The syntax of the redirection it contains is:
redirect /mywebsite/folderb http://remote/site/address

The preformatted text button in the editor did not work as expected, so my folder structure depicted above is not visually clear. The folder mywebsite is a subdirectory of htdocs and the other three folders are all subdirectories of mywebsite.

Further experimentation with this enables me to answer my own question.
This method of redirection does work here, but the .htaccess file must be placed in
the folder /htdocs to work. This is a bit surprising, because elsewhere it has worked
for me to place it in the folder to be redirected.

If you only want to redirect folders workout any content, you may want to redirect with the .htaccess Redirect keyword in the /htdocs/.htaccess file. See this example below.

Redirect 301 /mywebsite/ http://another.host/
Redirect 301 /mywebsite/foldera/ http://second.host/foldera
Redirect 301 /mywebsite/folderb/ http://remote/site/address

You can change the last url to whatever you want, it can even be internal. You can also change the 301 (Permanent) to 302 (Temporary).


Contrary to what you said, the method of redirection does work here, the cPanel does not really set it up properly. The correct syntax for a subdirectory is:

Redirect / http://moongazer.epizy.com/

I set up a demo at https://wkbl.cf/moongazer-epizy-com/folder/. You should also read about the Rewrite keyword.

2 Likes

Thank you wackyblackie. Actually, I withdraw my previous self-answer that the .htaccess file with the redirect has has to be in the htdocs folder. It is actually impossible to tell which change made the difference because of the long delay in the server’s reaction to changes due to the strong server-side caching.

This has actually become an additional problem for me, because the redirection was only an experiment and was never intended to be permanent, so once I established that the .htaccess redirect works, I removed it from the .htaccess file. However, it is still redirecting many hours after removing the redirect. And I can prove it’s not due to local caching in my browser, because, in addition to clearing my browser cache, I also tried accessing the page in a different, newly-installed browser in which I have never visited that site, and even there the redirection is occurring as if the redirect is still present in the updated .htaccess file.

I have tried disabling caching by following the advice of anon19508339 in this thread, but it hasn’t yet had the desired effect. I have seen other complaints on this forum about the server-side caching preventing website owners’ changes from taking effect within a reasonable time, and I hope there is a solution to that that works.

The is no server-side caching, and that’s what everyone does not understand. Not only can your web browser cache files, but so can your ISP (Internet Server Provider). If clearing your cache or using a private window does not solve the cache issue, the issue lies in your ISP.

1 Like

@Greenreader9 >There is no server-side caching

Really? In the thread about caching started by Wrecket in March 2020, which I linked to above, Admin replied, “Our servers enforce quite strong browser caching because it makes website appear faster and saves everyone in bandwidth costs. …” Although he used the term “browser caching,” he also added there, “There is no way to disable this caching”. Now since a local browser-cache can be cleared, what role is played in that caching by “our servers” mentioned by Admin in his reply to Wrecket? Furthermore, later in that same thread, Admin replied to Wrecket’s question, “So how is this resolved,” saying, “With patience. Or by setting .htaccess rules to disable cache, like @anon19508339 suggested, but that’s definitely not recommended, because it will slow down your website and increase server load, …” If there was no server-side caching, disabling it would not have the effects Admin warned of. Also, from the numerous online tips showing how to use .htaccess to disable caching, there must be something widely occurring server-side in relation to caching and I’d like to know what that is.

BTW, shortly after my earlier reply, the change took effect, so the immediate problem has disappeared for me, but I’d still like to understand what role web-servers (presumably including those run by InfinityFree) usually play in relation to caching.

That is still true.

Note the word “Browser”. The website headers are set up to use strong caching, which helps prevent suspension.

Although technically untrue, the method to remove this is not shared because it will lead you to quick suspension. .htaccess rules are a way to overcome this.

1 Like

Call me obtuse if you like, but could you elaborate a bit more on how this works and how this is linked to account suspension? If you mean suspension for inactivity, I would have thought that caching will contribute to that because instead of your browser downloading files from the server, it will just retrieve locally cached copies of files you have previously retrieved. If so, then won’t disabling caching increase activity and therefore reduce the likelihood of suspension? And in what way will .htaccess rules help with this? Obviously, I don’t know enough about this, or I wouldn’t be asking such questions, which probably sound stupid to you. Could you shed some more light on this?

Thanks for that @wackyblackie, but that link gives a 404 error. Has the page been deleted or is there a typo in the link?

It is moongazer.epizy.com that has the 404. This is only a demonstration of how Rewrite works.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.