i want to remove index.php from home page url
ex: https://url.com/index.php
change into
https://url.com/
and remove .php extension from other files
ex: https://url.com/contact.php
change into
https://url.com/contact
i want to remove index.php from home page url
ex: https://url.com/index.php
change into
https://url.com/
and remove .php extension from other files
ex: https://url.com/contact.php
change into
https://url.com/contact
You can append this to your .htaccess
file to make all PHP files have their extension removed. You're required to have mod_rewrite
enabled.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
As similarly seen here, adjusted to PHP.
By default, Apache will automatically look for index.php
if you enter a directory rather than a resource. So in that case, just don't type the index.php
part. If you want to change it from the filename index
to something else, you can modify the DirecctoryIndex in your .htaccess
file.
In the case of https://url.com/contact
, you can create a directory called contact
and put your index.php
file in that.
If you're passing arguments via the url and you don't want the user to see them, you can use javascript to change what is shown in the address bar.