Need help with htaccess RewriteRule

Discussion in 'Site & Server Administration' started by fr600, Dec 24, 2006.

  1. #1
    I have no idea about htaccess RewriteRule. I'm expecting someone here can help me with this.
    I need to send users from the firstline -to- secondline. Please help me with these three:

    // directory is alpha numeric
    images/newfolder/index.html
    -to-
    images/index.php?directory=./newfolder/
    Code (markup):
    // pagenumber is numeric only
    images/1/index.html
    -to-
    images/index.php?pagenumber=1
    Code (markup):
    images/sample-file-name/index.html?number=0&directory=./newfolder/
    -to-
    images/index.php?directory=./newfolder/&number=0&filename=Sample File Name.jpg
    Code (markup):
     
    fr600, Dec 24, 2006 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 ^images/([^.]+)/index\.html$ images/index.php?pagenumber=$1 [L]
    RewriteRule ^directory/([^.]+)/index\.html$ images/index.php?directory=./$1/ [L]

    Something has to be unique in each of them. aka...images for one of them. For something like

    images/sample-file-name/index.html?number=0&directory=./newfolder/

    mod_rewrite is worthless cause it's still not very search engine friendly, after the index.html.

    er, you should get rid of the index.html part.
     
    Nintendo, Dec 25, 2006 IP
  3. fr600

    fr600 Member

    Messages:
    22
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #3
    Thanks a lot. I'm gonna try this now.

    BTW, is it better to use index.php instead of index.html or it's better to remove index.html?

    EDIT:

    I get a blank screen. :(
    However, when I use full url for the latter part, it does work but the url in address bar changes to index.php?....

    Can you help me again plz?
     
    fr600, Dec 25, 2006 IP
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #4
    I would just get rid of the index.html

    Is

    domain.com/images/#/index.html

    the full URL you tried? And mod_rewrite doesn't change the links, the script has to be edited to do that.
     
    Nintendo, Dec 25, 2006 IP
  5. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #5
    nintendo, is there a variable that can be used in the .htaccess file to refer to the directory that the .htaccess file is residing in?

    thanks for your time.
     
    daboss, Dec 25, 2006 IP
  6. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #6
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /directory/
    RewriteRule ^$ wacko.php [L]

    is for for example making /directory/wacko.php and /directory/ the same.
     
    Nintendo, Dec 25, 2006 IP