1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Mode Rewrite to manage site versions

Discussion in 'PHP' started by hasheru, Apr 10, 2010.

  1. #1
    Hello everybody, I hope you can help me..

    I've a homepage, the homepage has many version's because of many updates. In my main-dir it looks like this :

    -main
    --version
    ---12.02.2010
    ---20.02.2010
    etc..

    Now I wan't to link the page if somebody's going on my site to the newest version. I thought it can be done with the mode_rewrite , I made something but the problem is, you can see that's in a subdir like this: http://www.domain.com/version/12.02.2010/index.php

    I want to have http://www.domain.com/index.php , is this posible?

    I hope you can help me out

    Thanks in advance.
     
    hasheru, Apr 10, 2010 IP
  2. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if you have "clean" urls, you can easily just set each regex to match to foldername/file.php.
     
    krsix, Apr 10, 2010 IP
  3. hasheru

    hasheru Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What do yo mean by that?
     
    hasheru, Apr 10, 2010 IP
  4. nimonogi

    nimonogi Active Member

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    80
    #4
    Add this to the .htaccess file in your root directory:
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/version/12.02.2010/
    RewriteRule ^(.*)$ /version/12.02.2010/$1
    
    Code (markup):
    Not tested but it should work.
     
    nimonogi, Apr 10, 2010 IP
  5. hasheru

    hasheru Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    He, THX but it didn't work. There isn't any error but the page isn't redirecting, it stays on the same root dir.
     
    hasheru, Apr 11, 2010 IP
  6. hasheru

    hasheru Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    he sorry, I must give the index.php then it works, how would it work without to give index.php ?

    now it looks like this

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/version/2010.04.11.1/
    RewriteRule ^(.*)$ /version/2010.04.11.1/$1
     
    hasheru, Apr 11, 2010 IP
  7. hasheru

    hasheru Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    hasheru, Apr 11, 2010 IP
  8. nimonogi

    nimonogi Active Member

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    80
    #8
    Replace the rule with this one and let me know:
    
    RewriteRule ^([^/]*)$ ./version/2010.04.11.1/$1 [L]
    
    Code (markup):
     
    nimonogi, Apr 11, 2010 IP
  9. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #9
    My shared host lets me have access to all configs - PHP, Apache, etc.
    If yours allows this, just change DocumentRoot to public_html/latest and symlink your latest version to latest.
    If yours doesn't allow this, change to a better host.
     
    krsix, Apr 11, 2010 IP
  10. hasheru

    hasheru Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    thx for helping me,

    @nimonogi, I tried this,

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/version/2010.04.11.1/
    RewriteRule ^([^/]*)$ ./version/2010.04.11.1/$1 [L]
    Code (markup):
    but it still didn't work.

    @krsix, I didn't ask but I don't think they let me do this..
     
    hasheru, Apr 11, 2010 IP
  11. Oceanus

    Oceanus Member

    Messages:
    903
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #11
    What about just doing a 301 redirect?
     
    Oceanus, Apr 11, 2010 IP
  12. hasheru

    hasheru Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    The problem is, that people can see the directory /version/2010.04.11.1/ and that's what keeps me off doing it.
     
    hasheru, Apr 11, 2010 IP
  13. Oceanus

    Oceanus Member

    Messages:
    903
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #13
    can you remove the periods?
     
    Oceanus, Apr 11, 2010 IP
  14. hasheru

    hasheru Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    what do you mean by periods?
     
    hasheru, Apr 12, 2010 IP
  15. nimonogi

    nimonogi Active Member

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    80
    #15
    Try this way:
    
    RewriteEngine On
    Options +FollowSymLinks
    
    DirectoryIndex index.php
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/version/2010.04.11.1/
    RewriteRule ^(.*)$ /version/2010.04.11.1/$1 [L]
    
    Code (markup):
     
    nimonogi, Apr 12, 2010 IP
  16. hasheru

    hasheru Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    He nimonogi thank you very much but I still must give index.php at the end of the domain to get on the site, otherwise it doesn't show the page.
     
    hasheru, Apr 12, 2010 IP
  17. hasheru

    hasheru Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    He thanks to you all, what nimonogi did was right except to let these 2 lines away:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    Code (markup):
    It functions like this:

    
    RewriteEngine On
    Options +FollowSymLinks
    
    DirectoryIndex index.php
    
    RewriteCond %{REQUEST_URI} !^/version/2010.04.11.1/
    RewriteRule ^(.*)$ /version/2010.04.11.1/$1  [L]
    
    Code (markup):
     
    hasheru, Apr 12, 2010 IP
  18. nimonogi

    nimonogi Active Member

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    80
    #18
    I'm glad I was able to help :)
     
    nimonogi, Apr 12, 2010 IP
  19. hasheru

    hasheru Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #19
    Thx very much;) but I've got another question, I'm searching for this about 2 hours. I wan't the redirecht in PHP to this version/2010.04.11.1/ dir which is no problem. In this dir 2010.04.11.1 I want to have a htaccess file in this dir 2010.04.11.1 which is removing the version/2010.04.11.1 from the url. Do you know how this would work? because I've problem when I redirect the page with htaccess in the root dir, then I can't get acces the a newer version( e.x. 2010.04.12.1 ).

    Thank you in advance.
     
    hasheru, Apr 12, 2010 IP
  20. nimonogi

    nimonogi Active Member

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    80
    #20
    This should do the trick:
    
    RewriteEngine On
    Options +FollowSymLinks
    
    DirectoryIndex index.php
    
    RewriteCond %{REQUEST_URI} !^/version/2010.04.12.1/
    RewriteCond %{REQUEST_URI} !^/version/2010.04.11.1/
    RewriteRule ^(.*)$ /version/2010.04.11.1/$1  [L]
    
    Code (markup):
    This code should replace the previous discussed.
     
    nimonogi, Apr 12, 2010 IP