Hi,

I'm on an Apache server.

I'm trying to create a permanent redirect of an entire website to a single page on the new site.

I'm using this:

Redirect 301 / http://www.cvm.org.uk/wales/index.php

Redirect 301 /links.php http://www.cvm.org.uk/wales/index.php

The first line works fine for the index.php page of the site.

The second line is for the links.php page which is in the root of the site but when redirected it links to: http://www.cvm.org.uk/wales/links.php which does not exist and therefore gets a 404 error.

I've ensured that I've uploaded the .htaccess file in ascii mode.

As an aside what I'd like to do is redirect the whole existing site to the one page in the new site (http://www.cvm.org.uk/wales/index.php) but I'm assuming that I'll need to redirect each individual page. Is that correct? Assuming it is then the attempt I'm making as described above isn't working. Any assistance in this would be greatly appreciated.

With a bit more searching whilst I was waiting for a reply I found this solution to my problem

RewriteEngine On
RewriteRule ^/* http://www.cvm.org.uk/wales/index.php [R=301,L]

This one rule redirects every single page in the site.

@arooney suggestion should work.

Could I ask why you want to do this?

If you have just upgraded your site this can be the wrong thing to do. Where possible, redirect to a relevant page, do not just send people home.

That will give your visitors a better experience as well as help the search engines discover and rank your new pages.

Yes I understand what you are saying but in this case the redirect is just to one page within the new site. It's not a new site as such but an area within an existing site that at the moment is just one page. So there are no relevant pages to redirect to if that makes sense. Thanks for pointing it out though, it's appreciated.

No worries

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.