0

I want to be able to do the following:

ReWrite /test -> /test.php

Also:

ReWrite /Test/test -> /Test/test.php

I want to be able to do this only for those mentioned urls. Also, I do not want direct access to .php urls. For example, if the user navigates to /Test/bla.php or any other links, he would be automatically be directed to the /index. The main reason I am doing this is that I do not want the user to know I am using .php. Here is what I tried:

RewriteEngine On
RewriteRule ^Test/test$ /Test/test.php
RewriteRule ^test$ test.php
ErrorDocument 404 /index.php

This works to some extent. I can navigate to /Test/test and it redirects me to /Test/test.php without issues. Though, if I do something like /test (from the root), I see the Test folder instead. Also, 404 does not work in this .htaccess above. I can navigate to any missing url and it complains that it is not there.

I am new to web hosting. So, I am kind of confused by the .htaccess.

Thanks for your time.

Kastov
  • 1
  • Possible duplicate of [How can I use .htaccess to hide .php URL extensions?](https://stackoverflow.com/questions/10028025/how-can-i-use-htaccess-to-hide-php-url-extensions) – Walf May 24 '18 at 14:14
  • There are already scores of questions that ask exactly that. How did you not see any relevant suggestions when typing this question? – Walf May 24 '18 at 14:17

0 Answers0