SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2011
    0 Post(s)
    0 Thread(s)

    How to fix mod_rewrite error


    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} !$ [NC]
    RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+) [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} !$ [NC]
    RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+) [NC]
    RewriteRule (.*) index.php?topic=%2 [NC,QSA]

    when i click like this in browser it shows me a blan page…

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


  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    19 Post(s)
    3 Thread(s)

    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.


    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts