How come this one line of htaccess isn't work?

Discussion in 'Apache' started by misohoni, Oct 22, 2011.

  1. #1
    RewriteEngine On
    RewriteRule ^([^_]*)\.html$ /oops.php?videoID=$1 [R=301,L]

    Am I doing anything wrong?
     
    misohoni, Oct 22, 2011 IP
  2. Sorror

    Sorror Active Member

    Messages:
    376
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    60
    #2
    And what are you trying to do?
     
    Sorror, Oct 27, 2011 IP
  3. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #3
    Thanks, an example would be changing:
    /oops.php?videoID=3416

    to
    /POSTNAME.html

    Wouldn't the above .htaccess covert it?
     
    misohoni, Oct 27, 2011 IP
  4. Sorror

    Sorror Active Member

    Messages:
    376
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Sorror, Oct 27, 2011 IP
  5. bvraghav

    bvraghav Member

    Messages:
    123
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    33
    #5
    What I can infer is that you are trying to respond to the request VIDEONAME.html using /oops.php?videoID=VIDEONAME

    A basic shortcoming might be using this regex
    # ^/([^_]*)\.html$ instead of ^([^_]*)\.html$
    RewriteRule ^/([^_]*)\.html$ /oops.php?videoID=$1 [R=301,L] 
    Code (markup):
    Secondly, it is necessary (or at least a good practice) to define RewriteBase
    RewriteEngine On
    RewriteBase /relative/deployment/url
    Code (markup):
    Irrespective of all this, I feel that it is much easier to tackle all this using the $_SERVER available in PHP
    The general wordpress .htaccess redirects all requests to the index.php in your deployment folder. You can now detect the requests from
    $_SERVER['REQUEST_URI']
    Code (markup):
    and define redirections. MVC Architecture seems apt in this scenario.
     
    bvraghav, Oct 30, 2011 IP