How can I tweak this rewrite rule to make it rewrite only VALID URLs?

Discussion in 'Apache' started by Darden12, Oct 28, 2008.

  1. #1
    The following htaccess rewrite rule is written in such a way that no user-entered URL will return a 404 error as long as the URL starts with my domain name.

    Google doesn't like that.

    Can someone tell me how to modify the following so that only real pages (i.e., only pages that actually exist on my server as index.php?FixedTitle=$1) will be rewritten and so that the user will otherwise get a 404 message?

    Thanks!
    Brian

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*)$ index.php?FixedTitle=$1
     
    Darden12, Oct 28, 2008 IP
  2. mortenb

    mortenb Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I would handle it with the php script. Send a 404 header with the index.php script of the FixedTitle variable is invalid.
     
    mortenb, Oct 28, 2008 IP
  3. Darden12

    Darden12 Well-Known Member

    Messages:
    107
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #3
    Thanks. That seems to have worked. Hopefully this will pacify Google, at least for the time being.
     
    Darden12, Oct 28, 2008 IP