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.

Dani AI

Generated

A few clarifications and safer options to complement ’s follow-up and ’s SEO point.

The behavior that surprises people usually comes from how Apache’s simple Redirect works: it will append the unmatched portion of the request to the target URL and rules are applied in order. That means a broad “catch‑all” redirect placed before page‑specific rules can mask the latter and produce unexpected target paths. Also remember that per‑directory (.htaccess) context can change what the left‑hand path actually matches.

Two concise alternatives that avoid the common pitfalls (replace the example target with the real landing page):

Redirect all requests to a single landing page (mod_alias / RedirectMatch)

RedirectMatch 301 ^/(.*)$ http://www.example.com/newpage

Safer mod_rewrite version that avoids redirect loops (useful if the new page lives on the same host)

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/newpage$
RewriteRule ^.*$ http://www.example.com/newpage [R=301,L]

Troubleshooting checklist: confirm the rule file is in the site’s DocumentRoot (and that AllowOverride + the relevant module are enabled), test redirects with curl -I to inspect the Location/Status headers, use a temporary 302 during testing because browsers aggressively cache 301s, and put specific redirects before any catch‑all. On the SEO side, be aware that mass‑redirecting many disparate pages to one unrelated page can be treated poorly by search engines (mapping old pages to relevant new content or returning proper 404/410 is preferable where appropriate).

These points explain why the initial Redirects can act oddly and offer two reliable patterns to perform a site‑wide permanent redirect while avoiding loops and unexpected appended paths.

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.

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.