I have created a .htaccess file that allows for vanity URLs. However, I am no longer able to type http://www.website.com without typing in the index file. I.e. I have to type in http://www.website.com/index.php in order to see the homepage. This is what my .htaccess file looks like:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^(.*)$ http://www.website.com/profile.php?u=$1 [NC]
Anyone know how to fix this? Thank you all!
The way you defined your rule increased the complexity.
Above rule means if file name is a directory of file process as it is. after that dont process farther.
This rule means map any request uri to
profile.php?u=Now when you request
/that iswww.website.comit checks the first rule and it fails to match. Then it check the second rule and maps it toprofile.php?u=.$_GET['u']is empty or/inprofile.php. If it is then load theindex.php.Another way is to find a proper regular expression for your user names once found use it here.
The best way to handle this is using PHP,
Now
index.phpwill get every uri you pass. Now you can process the URI inindex.php.