Apache2 redirect all sub-directories to index.html of main directory?

Apache2 redirect all sub-directories to index.html of main directory? - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the Apache2 redirect all sub-directories to index.html of main directory? error on your web browser. Problem :


I want to put an .htaccess file in a directory of my website. For this purpose in:



www.mysite.com/dir/


Then I want anything after /dir/ to direct to /dir/index.html but still display the original URL in the browser.
So for example:



www.mysite.com/dir/foo/bar -> www.mysite/dir/index.html


So in essence I want the browser to go to index.html but display the original URL
Could this be done with a reverse proxy?


Solution :

Sam's second comment was pretty close. This should work:



RewriteRule ^dir/(.*)   dir/index.html [NC,L]

We hope that this article has helped you resolve the htaccess, redirects, apache2 error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

Create redirect from url like www.example.us/?p=100&option=

Does a redirected URL used in an anchor count as backlink?