.htaccess redirect specific uri to diffrent php file and block access to all php files

I want to create .htaccess file which will allow user to access files if they exists but without those with php extension.

Also I want all non file URI redirected to index.php (include all php files) but with one specific URI like

http://website.com/exception
http://website.com/exception/webpage.php
http://website.com/exception/webpage/all
I want to redirect to example.php. Both php files will be in root folder alongside .htaccess. I need your help because I’ve wasted couple of hours and got nothing.

1st of all you need to know if your server is windows based or Linux based. If the server is Linux based the you will try this link for redirection - .htaccess redirect specific uri to diffrent php file and block access to all php files

Why does it matter if it’s Windows or Linux, @soumyadip? OP has already indicated he’s using Apache.

I don’t see see where indicated he’s using Apache. If he is using Apache then my reference working smoothly. I am asking the sever name because some windows server not support those .htaccess code. Also I am not too familiar with windows server.

Did you just linked my thread in your answer?

I was referring to the fact that it’s an .htaccess file, since AFAIK IIS and Nginx use different config files.

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