0

I have a website we'll call it domain.com, that was originally written in PHP. Every single valid URL contains the letters "php" somewhere after the "domain.com/" part.

I recently finished a complete rewrite of the site using Django, currently located at beta.domain.com

What I want to do is move the old PHP site to old.domain.com, and move the new beta site to domain.com. I want to do this without missing a beat. I want all old links to redirect to the new subdomain. This also includes linked images (that end in .php).

3 Answers 3

1
  • If yout old domain was well written (not use absolute, hard coded URIs and so on) you can the job very very easy, simply swapping the VHosts' DocumentRoot

  • if not then you can recur to mod_rewrite. This issue is abundantly treated on SF (#66285 can be a starting point)

1
  • Part B is the best answer based on your description -- you're going to need to write RewriteRules based on the config of your old site (images ending in .php?) to point to the new location/home on the new site, which presumably have changed location and name.
    – user15590
    Sep 23, 2009 at 21:44
0

If you are looking to redirect the entire old.domain.com site to domain.com (new site) then a .htaccess on old.domain.com with:

Redirect / http://domain.com

This will redirect all requests from old.domain.com/anything to the new one (the main homepage).

If you are looking for 1-to-1 redirects, for example old.domain.com/directory/file.php -> domain.com/directory/file then you would need to create mod_rewrite rules for this, assuming you are on Apache.

0

I just came up with a very simple solution to this. My solution only really works with Django, but I image the concept can be applied to other web frameworks.

First, direct all domains to the django app. At the bottom of the urls.py, add this:

(r'\.php', "redirect.views.redirect", ),

Then create an app called "redirect", and in the views.py file, add this:

def redirect(request):
    """redirect any url with '.php' to the old PHP version"""
    return HttpResponseRedirect("http://old.domain.com" + request.get_full_path())

It's probably not the most efficient way to do this, but eh, it seems to work. It sure beats mucking around with .htaccess files, which seem to be impossible to test before deploying...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .