Mod rewrite - variable rewriteBase

Discussion in 'Apache' started by StrobeNet, Jan 11, 2007.

  1. #1
    Hi,

    I need to find a way to have the rewriteBase change depending on the URL.
    for example, if the URL contains the string "sslserver" then the rewriteBase should be /oursite/.
    if the URL does not contain the string "sslserver" then the rewriteBase should be /.

    Does anyone know if this is even possible?

    cheers,
    StrobeNet
     
    StrobeNet, Jan 11, 2007 IP
  2. noname

    noname Peon

    Messages:
    26
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    put some examples it would make it easier to understand what you want

    A -> B
     
    noname, Jan 11, 2007 IP
  3. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #3
    Post the original URL and how you want it. If you're just making the strings be directories, you don't need a rewriteBase for every one of them, just one.
     
    Nintendo, Jan 12, 2007 IP
  4. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Are you sure you can't do it with rewriteCond?

    Something like:
    RewriteCond %{REQUEST_URI} sslserver
    RewriteRule (.*) oursite/$1 [L]
    
    RewriteRule (.*) $1
    Code (markup):
    Obviously the second rule is useless in that case, but I don't know what you want doing.

    First it checks the request for 'sslserver' and if it does contain that it rewrites to the directory 'oursite' and stops rewriting (L flag). Otherwise it carries on with the rewrite rules (no 'sslserver') and rewrites to the / directory instead.
     
    rodney88, Jan 13, 2007 IP
  5. StrobeNet

    StrobeNet Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi,

    I am unsure of the syntax for the following but this is how I would imagine it would look.

    RewriteCond %{REQUEST_URI} sslserver
    RewriteBase /oursite/
    RewriteRule (.*) /oursite/$1 [L]

    RewriteCond %{REQUEST_URI} !sslserver
    RewriteBase /
    RewriteRule (.*) /$1 [L]

    So, I want to be able to change the rewriteBase depending on if the URL contains the string "sslserver";
     
    StrobeNet, Jan 14, 2007 IP
  6. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #6
    A wise man once said....

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)$ WHATEVER.php?WHATEVER=$1 [L]

    and change WHATEVER to WHATEVER it is in the original URL.
     
    Nintendo, Jan 15, 2007 IP
  7. StrobeNet

    StrobeNet Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    the RewriteRule is not the problem, that has been working fine the whole time, and I am able to change the RewriteRule depending on if the URL contains "sslserver" fine aswell.

    The problem is changing the RewriteBASE depending on the URL...

    I dont think I am going to get any answers here so I will be moving on...

    thanks anyway
     
    StrobeNet, Jan 16, 2007 IP
  8. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #8
    RewriteBase only works if it's a real directory. Hince you use RewriteRule to make the directories.
     
    Nintendo, Jan 16, 2007 IP