Jump to content

Recommended Posts

Posted

I built best-of-scotland.co.uk on Processwire and have a redirect problem.

Tried method 1:

If I add the line to the .htaccess file I get a site error. At the bottom or the top of  the file I tried adding

Redirect 301 /index.php/contact http://best-of-scotland.co.uk/contact/

Tried Method 2:

Using the redirect module (http://modules.processwire.com/modules/process-redirects/) does not seem to work at all.

For example this page http://www.best-of-scotland.co.uk/index.php/contact was the old page and we are trying to get it to redirect to http://www.best-of-scotland.co.uk/contact.

Is there a way to redirect an old site with SEO rewritten URLs to the new site?

Posted

Method 1 does not work because the syntax is not correct. Try adding the redirect like this in the .htaccess, before Pw does handle the request itself:

<IfModule mod_rewrite.c>

  RewriteEngine On
  AddDefaultCharset UTF-8

  #Redirect here
  RewriteRule ^/index.php/contact$ /contact/ [R,L]

Why does Redirects not work? Any errors?

If your page-names in ProcessWire have the same name as on your old site, you could setup a rule like this:

RewriteRule ^/index.php/(.*)$ /$1/ [R,L]
  • Like 2
  • 4 months later...
Posted

I'd like to dig up this topic as I have a similar problem...

I had a site with two separate sections under one domain, which then was split up into two separate sites with their own domains.

Now I'm trying to set 301 redirects to all broken links.

I added this to my .htaccess:

RedirectMatch 301 /new/(.*) http://www.newdomain.com//$1 

So if you type in www.olddomain.com/new/about you should be redirected to www.newdomain.com/about.

This does work, sort of. But the result is www.newdomain.com/about?it=new/about, which causes a page not found error.

How do I get rid of the ?it=new/about part?

Posted

Try adding this line before your redirect:

RewriteCond %{THE_REQUEST} ^.*/index.php

Also, remove the second forward slash: //$1 should be /$1

Posted

I already have that line, followed by a RewriteRule...

RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ /$1 [R=301,NC,L] 

This is for redirecting to the base url, so if someone enters mydomain.com/index.php he gets redirected to mydomain.com

But even if i remove the rewrite rule line, still the same effect.

I removed the typo with the second slash, but that seemed not to be the problem.

I don't really understand how this part "?it=something/else" is generated... Is there a way to cut it off just for the redirect?

Posted

Try this:

Redirect 301 /new http://www.newdomain.com

That should keep things simple.  Nevermind - that won't obviously take care of the pages below /new/

If it still doesn't work, try removing your index.php redirect as a way of testing this first.

Posted

thanks. the thing is, the redirect is actually working... it's just the additional "?it=blah/bleh" part that makes the url unusable.

I just don't know how to remove it (or prevent PW from adding it automatically)... any ideas?

Posted

Just to clarify things first.

You have an actual page on your new domain that is newdomain.com/about/ ?

First I wanted to mention that all urls in ProcessWire by default are with a trailing slash (unless you change template settings of this). And acessing newdomain.com/about will redirect you to /about/

Posted

yes, the page I'm redirecting to is the actual page newdomain.com/about/ , redirecting from the (no longer existing) olddomain.com/new/about/

the result is the same with or without the trailing slash...

can anyone explain to me, why this ?it=/new/about/ part is appended at all in the first place? i just don't understand why and how this is happening...

Posted

It's coming from ProcessWire also set in .htaccess.

I'm not sure depends where you set your redirect rule. It would be at the top before processwire ones.

If that's already the case, I think you'd maybe need a different rule to sort that out.

Posted

Ah, I think I'm getting closer... this rule is where the path is appended for use in processwire

RewriteRule ^(.*)$ index.php?it=$1 [L,QSA] 

I solved it with a RewriteRule instead of a redirect

RewriteCond %{REQUEST_URI} ^.*/new/(.*)
RewriteRule ^new/(.+)$ http://www.newdomain.com/$1  [R=301,L]

RewriteRule ^new/(.*)$ http://www.newdomain.com/$1  [R=301,L]

I put this before all the other rewrite conditions. It redirects all requests containing the /new/ path to the new domain homepage, and also appends any path segments which might come after /new/. So www.olddomain.com/new/about/ becomes www.newdomain.com/about/ ...which is exactly what I wanted.

Thanks for pointing me in the right direction!

-------------------------------

Edit: the rewrite condition is not even necessary, and to execute the rule for just www.olddomain.com/new/, the + has to be replaced by a *.

Yay! :)

  • Like 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...