I have to run multiple website versions on some logic. say, for all users registered after Jan 2014, I have to display newer version of websites and for older users I have to display older version of my website.
Web servers: nginx for static content and apache for dynamic content.
platform: php, mysql and linux
For user coming to my website, I have to check registration date and accordingly redirect user to respective website version. but I want to prevent this extra redirect.
Is the same possible using cookies, proxy or something?
Problem statement:
I have revamped my website. I want that my revamped site will be shown to new registered users only. For existing users older version will be continued. Web roots are different for both website versions.
nginx configuration:
server {
listen 80;
server_name example.com;
location /
{
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-FORWARDED_PROTO https;
set $cookie_redirect 0;
if ($http_cookie ~ 'ver=1' ) {
set $cookie_redirect 1;
}
if ($cookie_redirect ~ 1) {
proxy_pass http://127.0.0.1:6060;
}
if ($cookie_redirect ~ 0 ) {
proxy_pass http://127.0.0.1:7070;
}
}
apache configuration:
<VirtualHost *:6060>
DocumentRoot /var/www/dir1
ServerName example.com
</VirtualHost>
<VirtualHost *:7070>
DocumentRoot /var/www/dir2
ServerName example.com
</VirtualHost>
But it will work if cookies are set. For users who are coming first time and I have to set cookies on the basis of registration date. so that I will be able to show revamped site to new users. How the same is possible for first time users?
This wouldn't be much of a problem if your site uses a proper template engine in the first place.. php is backend, therefore just run the checks for the registration date before your content rendering and then display the content accordingly. this is pretty much what any website does anyways, in a way or another.