Reputation: 17
I have been playing around with this for ages, and just can't seem to get it to work - I don't know if it's an issue with .htaccess, or the fact that I'm using MAMP @ localhost:8888.
I'm trying to clean up my URLS from;
localhost:8888/profile.php?user=testuser
to
localhost:8888/testuser (localhost:8888 will be replaced by my TLD once live).
The code I'm trying to use in my .htaccess
is;
RewriteEngine On
ReWriteRule ^([a-z]+)$ profile.php?user=$1
(I've also tried adding http:/localhost:8888/
before the ^)
I am getting a 404
Can anyone help, as this is driving me nuts!
Upvotes: 1
Views: 97
Reputation: 26
It seems you are missing the /. Your ModRewrite does not recognize it by default. So your Browser is trying to find the folder "testuser" within your root directory.
Please have a look in here:
https://www.sitepoint.com/forums/showthread.php?288690-Mod-Rewrite-simulating-a-folder-structure
Edit:
Try this:
RewriteRule ^([^/]+)/$ /profile.php?user=$1
Upvotes: 1