Website Versioning with htaccess

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Website Versioning with htaccess

Post by onion2k »

Is there a way to make versions of a website that you can easily control with htaccess? For example, imagine the following directory structure..

Code: Select all

/1.0/index.php
/1.0/stuff.php
/1.0/images/image.gif
/1.0/css/site.css
 
/2.0/index.php
/2.0/stuff.php
/2.0/images/image.gif
/2.0/css/site.css
 
Is there a way to make a rewrite rule that says domain.com/index.php points to domain.com/1.0/index.php, and domain.com/stuff.php points to domain.com/1.0/stuff.php, and so on? Then just by changing the 1.0 to 2.0 in htaccess, switch from one version to the other?

It feels like there should be, but so far everything I've tried has failed.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Website Versioning with htaccess

Post by pickle »

This is what worked on my server:

Code: Select all

Options +FollowSymLinks
RewriteEngine on
RewriteBase /versioning/
RewriteRule ^([^1].*)$ 1/$1
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Website Versioning with htaccess

Post by onion2k »

Ahh.. I was trying to take too much of a shortcut I think. That seems to work pretty well. Cheers.
Post Reply