Hopefully a slightly different mod_rewrite problem...

Discussion in 'Apache' started by uprightdog, Aug 14, 2005.

  1. #1
    Another mod_rewrite question I'm afraid!

    I'm trying to use mod_rewrite to enable friendly URLS... you know the score - rewriting /mydirectory/myfile/100/ to /mydirectory/myfile.php?myparameter=100 etc. I've used mod_rewrite to do this before, and don't usually have any problems.

    The rule I'm using is similar to this:
    RewriteRule ^mydirectory/([^.]+)/([0-9]+)/$ http://forums.digitalpoint.com/ [L]

    Now, using this rule, if the URL was mydirectory/somerubbish/1/, the rewrite works perfectly.

    However, if the URL is mydirectory/index/1/ - keeping in mind that I do have a file called index.php - the rewrite fails, and index.php loads instead of digitalpoint.

    The same applies for any string following mydirectory/, where that string is a filename. The fact that a file of that name exists (regardless of the missing extension) seems to over-ride the rewrite.

    What am I doing wrong?
     
    uprightdog, Aug 14, 2005 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^/mydirectory/myfile/([^.]+).html$ /mydirectory/myfile.php?myparameter=$1 [L]

    /mydirectory/myfile/100.html
     
    Nintendo, Aug 15, 2005 IP
  3. uprightdog

    uprightdog Guest

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Didn't make any difference. I've got it now, however - had to turn off multiviews in htaccess.
     
    uprightdog, Aug 15, 2005 IP