.htaccess url rewrite

Discussion in 'PHP' started by manivannang, Jun 27, 2011.

  1. #1
    manivannang, Jun 27, 2011 IP
  2. rainborick

    rainborick Well-Known Member

    Messages:
    424
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    120
    #2
    I think you need something like:
    
    RewriteCond %{REQUEST_URI} ^/video/play.php$
    RewriteCond %{QUERY_STRING} ^name=(\w+)&ext=(\w+)$
    RewriteRule ^/video http://www.test.com/video/%1\.%2? [R=301,L]
    
    Code (markup):
    (set to do a 301 redirect). But I'm not an .htaccess expert and so you'll probably have to experiment with that code to get just what you want.
     
    rainborick, Jun 27, 2011 IP
  3. bogi

    bogi Well-Known Member

    Messages:
    482
    Likes Received:
    16
    Best Answers:
    2
    Trophy Points:
    140
    #3
    Check this one, please :eek:

    
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteRule ^video/(\w+).(mp4|flv|mpeg|whatever_extension)$ video/play.php?name=$1&ext=$2 [QSA,L]
    
    Code (markup):
     
    bogi, Jun 27, 2011 IP
  4. manivannang

    manivannang Peon

    Messages:
    117
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks Rainborick and bogi. i tried both the method but i still get 404 not found.
    btw i placed .htaccess inside video folder. hope its correct
     
    manivannang, Jun 27, 2011 IP
  5. SSC

    SSC Active Member

    Messages:
    995
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    #5
    Hope i am not interrupting a healthy conversation here, but i think you should put .htaccess in the root of your server.
     
    SSC, Jun 27, 2011 IP
  6. bogi

    bogi Well-Known Member

    Messages:
    482
    Likes Received:
    16
    Best Answers:
    2
    Trophy Points:
    140
    #6
    Yep, it should be placed in your root folder...
     
    bogi, Jun 27, 2011 IP