Dumbest mod_rewrite question ever

Discussion in 'Apache' started by Scorpiono, Mar 10, 2007.

  1. #1
    Scorpiono, Mar 10, 2007 IP
  2. andre75

    andre75 Peon

    Messages:
    1,203
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I guess this is what you really want:
    RewriteCond %{HTTP_HOST} ^video\.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

    The first line checks if the request is for the video subdomain.
    The second and third line check if the filename or the directory exist and if they do doesn't apply the rewrite.
    The 4th is the actual rewrite.
    If someone types video.mylol.net/sexyclips they will be redirected to video.mylol.net/index.php?fun=sexyclips but their browser still shows video.mylol.net/sexyclips.
    Not sure about the backslash. You probably have to use one more rewrite first to remove it
    video.mylol.net/sexyclips/ to video.mylol.net/sexyclips
     
    andre75, Mar 10, 2007 IP
  3. Scorpiono

    Scorpiono Well-Known Member

    Messages:
    1,330
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Didn't worked out, still thanks.
     
    Scorpiono, Mar 11, 2007 IP
  4. andre75

    andre75 Peon

    Messages:
    1,203
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well, I didn't bother to test the code. It was meant as a reference. However this is how you can do it. Maybe you should start by letting us know what didn't work out.
     
    andre75, Mar 11, 2007 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #5
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)/$ index.php?fun=index.php?fun=$1 [L]
     
    Nintendo, Mar 12, 2007 IP
  6. Scorpiono

    Scorpiono Well-Known Member

    Messages:
    1,330
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    120
    #6
    Ty Nintendo! You pwn!
     
    Scorpiono, Mar 12, 2007 IP