Reputation: 194
I am having problems getting what I think should be a simple htaccess rewrite to work...
Current URL: http://www.website.com/profile.php?id=61338848
Desired URL: http://www.website.com/61338848
Current htaccess code:
RewriteEngine On
RewriteRule ^([^/]*)$ /profile.php?id=$1 [L]
Result from the above htaccess is INTERNAL SERVER ERROR:
I would also like it to work for a custom domain (if set) although I am sure the solution priovided for the above will work just as well.
Desired URL: http://www.website.com/customdomain
Thanks in advance.
Upvotes: 0
Views: 1391
Reputation: 5730
i used this .htaccess
and it works for me:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)$ profile.php?id=$1 [L,QSA]
The QSA
flag is used, that you can add multiple get parameters like this: http://www.website.com/61338848?parameter=value
RewriteCond %{REQUEST_FILENAME} !-f
checks if the request_filename
is a file, if yes, the RewriteRule
will not be executed
Upvotes: 1
Reputation: 405
Try to remove the /
before the filename, like:
RewriteRule ^([^/]*)$ profile.php?id=$1 [L]
It worked for me.
Upvotes: 1