Reputation:
I'm attempting to use htaccess to write my urls as localhost/username instead of localhost/profile.php?id=username
I looked it up and this is what I found to be the solution
DirectoryIndex index.php
RewriteEngine On
RewriteRule ^(.*)$ /profile.php?id=$1 [L]
That's an exact copy from this stackoverflow question htaccess rewrite for query string however, for some reason it always returns a 500 error. I'm not sure why it's giving me this since I'm no expert with htaccess. I pretty much just find code modify it to fit my use.
Mod_rewrite is definitely turned on. So I know that can't be the issue. Any idea what is wrong with the code I have?
Edit:
This is what the apache error log returned.
[Sat Apr 27 14:20:10.558122 2013] [core:error] [pid 3244:tid 1688] [client 127.0.0.1:58653] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
Upvotes: 0
Views: 78
Reputation: 337
The part where it says /profile.php?id=$1
is where it will rewrite you to. If that;s not a file then it would show up with an error so change that to whatever file you want it to rewrite you to.
Hope this helped
Upvotes: 0
Reputation: 78473
If it's really a redirect loop per your comment, try adding this line immediately before your rule:
RewriteCond %{REQUEST_URI} !-f
Upvotes: 1