SitePoint Sponsor

User Tag List

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

    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

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,679
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    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
    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


Bookmarks

Posting Permissions

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