How to fix mod_rewrite error

Hi,

Can any one solve this… my problem is when i write the code for mod_rewrite it says 500 internal server error.

the code is like this:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !www.aapkapaper.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).aapkapaper.com [NC]
RewriteRule (.*) index.php?topic=%2 [NC,QSA]

after i delete the first line it didn’t through the error but the mod rewrite code is not worked…

after delete the code is like this:

RewriteEngine on
RewriteCond %{HTTP_HOST} !www.aapkapaper.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).aapkapaper.com [NC]
RewriteRule (.*) index.php?topic=%2 [NC,QSA]

when i click http://www.aapkapaper.com/?test.php like this in browser it shows me a blan page…

can anyone help for this as i am new in this….

thanks

k111,

The 500 error is typically because of a syntax error. If it went away when you removed the first line, the first line was using an improper format.

If you mean to match the dot character in your {HTTP_HOST} or {REQUEST_URI} (RewriteRule) variables, then you should use \. (unless it’s within a character range definition).

Your No Case flags are good in your RewriteCond statements but are improper in a RewriteRule (because directory and filenames are case sensitive while host names are not).

Your test URI (as shown) makes the second atom created null so your index.php’s value for $_GET[‘topic’] will also be null. If that makes the output of your page null, also, what is the surprise? Okay, it’s more likely that you’ve not accounted for the null value so it’s more likely that you’re getting an error from your database query which is causing the index.php script to fail.

Regards,

DK