htaccess rewrite

Discussion in 'Apache' started by userman, Sep 26, 2012.

  1. #1
    Hi,

    I have this working:
    RewriteEngine on
    RewriteMap lowercase int:tolower
    RewriteCond $1 [A-Z]
    RewriteRule ^/dir1/(.*)$ /dir1/${lowercase:$1} [R=301,L]

    How can i add another RewriteRule with the dir2 and dir3??

    I add the line:
    RewriteRule ^/dir2/(.*)$ /dir2/${lowercase:$1} [R=301,L]

    but dont work, i get error when i got to dir2/file...

    Regards.
     
    Last edited: Sep 26, 2012
    userman, Sep 26, 2012 IP
  2. plussy

    plussy Peon

    Messages:
    152
    Likes Received:
    5
    Best Answers:
    9
    Trophy Points:
    0
    #2
    you could try this. If this works you only need one line for all 3 directories

    
    [COLOR=#111111]RewriteRule ^/dir([1-3])/(.*)$ /dir$1/${lowercase:$2} [R=301,L][/COLOR]
    
    Code (markup):
     
    plussy, Sep 27, 2012 IP
  3. userman

    userman Active Member

    Messages:
    158
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Thanks plussy, but the directories have names, no numbers, i write dir1,2,3 for example only.

    RewriteRule ^/di1/(.*)$ /dir1/${lowercase:$1} [R=301,L]
    RewriteRule ^/anotherdir/(.*)$ /anotherdir/${lowercase:$1} [R=301,L]
    RewriteRule ^/etcdir/(.*)$ /etcdir/${lowercase:$1} [R=301,L]

    how can i make it?

    regards.
     
    userman, Sep 27, 2012 IP
  4. userman

    userman Active Member

    Messages:
    158
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    I get the solution:

    RewriteCond $1 [A-Z]
    RewriteRule ^/onefolde/(.*)$ /onefolder/${lowercase:$1} [R=301,L]
    RewriteCond $1 [A-Z]
    RewriteRule ^/otherfolde/(.*)$ /otherfolder/${lowercase:$1} [R=301,L]

    I use the code again :)

    regards.
     
    userman, Sep 29, 2012 IP