Reputation: 5
I am getting thrown errors every time i implement this code for mod-rewriting in my .htaccess file
RewriteEngine On
RewriteRule ^commenting/([0-9]+)/?$commenting.php?id=$1
I am trying to convert
domain/commenting.php?id=15
Into something like
domain/commenting/15
Is it a problem with the code or my hosting. I have not downloaded any plug-ins is that needed? Any help would be greatly appreciated, Thanks
The error is this:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator and inform them of the time the error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Upvotes: 0
Views: 1626
Reputation: 19528
You're missing a space between the left and right hand of the rule.
RewriteRule ^commenting/([0-9]+)/?$ /commenting.php?id=$1
You may as well need to enable the RewriteEngine
and Options
resulting on the following:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteRule ^commenting/([0-9]+)/?$ /commenting.php?id=$1
If you're still getting 500 after this try placing the above rule between these tags <IfModule mod_rewrite.c>...</IfModule>
like this:
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteRule ^commenting/([0-9]+)/?$ /commenting.php?id=$1
</IfModule>
The above basically means to execute the rules only if the module that makes it work is available.
Upvotes: 1