I want to redirect using .htaccess abc.com/test.php
to abc.com/test
. but it will execute/display the content of test.php only.
how should I do this? any suggestions?
I want to redirect using .htaccess abc.com/test.php
to abc.com/test
. but it will execute/display the content of test.php only.
how should I do this? any suggestions?
Try that
RewriteRule ^test$ test.php [L]
[update]
A complete redirect
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME}/ -d
RewriteCond %{SCRIPT_FILENAME}.php !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.+)\.php$ /$1 [R=301,L]
RewriteCond %{SCRIPT_FILENAME}.php -f
RewriteRule [^/]$ %{REQUEST_URI}.php [QSA,L]
This is accomplished using Rewrite Rules, rather than redirects. Something like this:
RewriteEngine On
RewriteRule ^/test.php$ /test [L,QSA]