Need Quick Help With 301ing .htaccess

Discussion in 'Apache' started by Quozt, Jan 10, 2007.

  1. #1
    I carnt figure out why this isn't working

    it keeps putting program as index.php [NC]

    if anyone could help that could be fantastic
     
    Quozt, Jan 10, 2007 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Firstly, I don't think you need to repeat both lines....
    RewriteRule shows/(.*) shows/index.php?program=$1 [R=301,NC]
    Code (markup):
    should do exactly the same as:
    RewriteRule shows/(.*)/ shows/index.php?program=$1/ [R=301,NC]
    Code (markup):
    since the period matches any character, including a forward slash.

    About your problem - the rewriting is being done twice. Let's assume the original request is for shows/donkeys. This matches the pattern shows/(.*) so it gets 301 redirected to shows/index.php?program=donkeys
    This is now a new request for shows/index.php, the rewrite rules still apply so
    shows/index.php is rewritten to shows/index.php?program=index.php

    Try something along the lines of:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{SCRIPT_FILENAME} !index.php$
    RewriteRule shows/(.*)/episode/(.*) shows/index.php?program=$1&episode=$2 [R=301,NC]
    RewriteCond %{SCRIPT_FILENAME} !index.php$
    RewriteRule shows/(.*) shows/index.php?program=$1 [R=301,NC]
    Code (markup):
     
    rodney88, Jan 10, 2007 IP