I'm developing a website using PHP. I'm trying to hide any PHP extension, using .htaccess.
This is my link urls for visiting an user profile :
<a class="nav-link" href="user/<?php echo"$username"; ?>"><i class="fa fa-user ispace"></i><?php echo"$username"; ?></a>
and this is my .htaccess rules:
RewriteRule ^user/(.*)$ profile.php?user=$1 [L,QSA]
But when I click on an user profile link, my bootstrap isn't loaded.
Also, the user header link redirects to www.mysitename.com/user/home and then shows a 404 error. How to fix this?
Thanks !
To hide the .php extension:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
To hide the .html extension:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
Put the .htaccess on the main Folder.
To test just do something like:
<a href="tests">Test go to .php file</a>
Should work.