Home » Php » How to redirect example.com/subdirectory/anything to example.com/subdirectory using .htaccess

How to redirect example.com/subdirectory/anything to example.com/subdirectory using .htaccess

Posted by: admin October 26, 2017 Leave a comment

Questions:

On the root directory of my domain an code-igniter(PHP) application is being served.

that application has its own .htaceess and own rewrite rules.

I have one more angular application. Since code igniter application is in root I don’t have any option but to keep angular application in the same directory.

So now its being served like

Code igniter application is on : example.com

angular application is on : example.com/app

My angular application is in HTML5 mode so its making urls like

example.com/app/somestate/statepera1/statepera1

and this works fine within the app. But when I try to open the same url directly. It gives me 404

so how do I serve example.com/app/ on example.com/app/somestate/statepera1/statepera1 so that my angular app can take care of the rest.

I guess its possible using .htaccess. Thats why I mentioned it in title.

Answers: