I moved old website to subdomain and installed Drupal 7 on main domain and would like to rewrite urls to the subdomain.

Old urls where in format index.php?main=something..... And I want to achieve that when somebody uses those old urls, it will redirect him to:
http://old.domain.com/index.php?main=something....

I tried to add this rewrite line:
rewrite ^/(index\.php\?main=.*)$ http://old.domain.com/$1 last;
into /data/disk/o1/config/server_master/nginx/vhost.d/domain.com file, restarted nginx service restart nginx, but it doesn't do anything and users still stay on main domain.

Where should I put rewrite rule, or what should I do to achieve redirection?

Comments

omega8cc’s picture

Try to add this rewrite in the nginx_vhost_include.conf file, as explained in: http://drupalcode.org/project/octopus.git/blob/HEAD:/docs/HINTS.txt

rewrite ^/(index\.php\?main=)(.*)$ http://old.domain.com/$1$2 permanent;

anantagati’s picture

I created file nginx_vhost_include.conf in /data/disk/o1/config/server_master/nginx/post.d directory and pasted rewrite text. Also tried service nginx restart, but it still doesn't redirect.

omega8cc’s picture

Category: feature » support
anantagati’s picture

Status: Active » Fixed

Seems like query string has to be handled separately.

This is working:

if ($query_string ~ main=.*) {
rewrite ^ http://old.example.com/index.php permanent;
}
omega8cc’s picture

Or when you want to send the request with URI+args:

if ($query_string ~ main=.*) {
  rewrite ^ http://old.example.com/$request_uri permanent;
}

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.