redirect old pages

Get help with installation and running PivotX 2.0.x here. Please do not post Extension or Theme related questions here.

redirect old pages

Postby knut » Tue Jun 17, 2014 3:38 pm

Hi,

I updated my website content and structure which leads to some pages (=URLs) does not exist anymore. But these URLs are linked on other website or search engines. How could I redirect the old URLs to my new pages?

knut
knut
 
Posts: 7
Joined: Thu Mar 07, 2013 2:38 pm

Re: redirect old pages

Postby hansfn » Tue Jun 17, 2014 4:24 pm

If you use Apache, this is fixed either by using Redirect directives, if it's only a few pages, or with RewriteRule directives, if it is many pages (with a given URL pattern). You put the directives in your .htaccess file. There are some example in the forum if you search and there are plenty examples on the web in general.

PS! This isn't really a PivotX specific questions, but you can ask here if you aren't able to find the solution yourself.
hansfn
Developer
 
Posts: 3282
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: redirect old pages

Postby knut » Wed Jun 18, 2014 4:10 pm

thanks for the Redirect approach. This way the client / search engine gets notified that the requested site is outdated.
knut
 
Posts: 7
Joined: Thu Mar 07, 2013 2:38 pm

Re: redirect old pages

Postby knut » Fri Jun 20, 2014 2:48 pm

ok, this does not work as expected :(

I edited .htacess:
Redirect /oldpage /newpage

now when I access www.mydomain.com/newpage the browser ends here:

http://www.mydomain.com/newpage?uri=old ... write=page

and I see the old page...
Any suggestions?
knut
 
Posts: 7
Joined: Thu Mar 07, 2013 2:38 pm

Re: redirect old pages

Postby hansfn » Sat Jun 21, 2014 5:25 pm

It's impossible to help you with this little (and generic) information. Just paste in your .htaccess file (or at least the modifications from the standard file - and were you added your stuff). It's also much easier if you can link to your site, but it might not be needed in this case.
hansfn
Developer
 
Posts: 3282
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: redirect old pages

Postby knut » Mon Jun 23, 2014 4:06 pm

hmm, it is not more complex. The htaccess is the original one with only the Redirect line added, like stated above. To be exact I have two pages to redirect and my htaccess looks like:

DirectoryIndex index.php index.html index.htm

Redirect /old1 /new1
Redirect /old2 /new2

RewriteEngine On
# RewriteBase /

# Standard PivotX rules for non-crufty URLs. The rules always work, but non-crufty
# URL must be enabled in the PivotX configuration too before they are actually used.
# If you have enabled localized rewrite prefixes (for page, entry, category, archive
# and so) you need to update/duplicate the rules below accordingly.
RewriteRule ^archive/(.*)/trackback/?$ index.php?trackback&uri=$1&rewrite=archive [L,QSA]
...
knut
 
Posts: 7
Joined: Thu Mar 07, 2013 2:38 pm

Re: redirect old pages

Postby hansfn » Mon Jun 23, 2014 5:06 pm

Why are you so reluctant to provide the actual redirects (and a link to your site)?

Anyway, you wrote

This didn't make any sense so I had to set it up on my own test site to see what really happens. Some testing quickly revealed that you meant "when I access http://www.mydomain.com/oldpage".

The solution is to use RewriteRule in stead of Redirect to avoid conflicts with later rewrite rules. Just after the RewriteBase line add:

Code: Select all
RewriteRule ^old1$ new1 [L,R=301]
RewriteRule ^old2$ new2 [L,R=301]
hansfn
Developer
 
Posts: 3282
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: redirect old pages

Postby knut » Tue Jun 24, 2014 12:34 pm

sorry, I don't want to post a link here.

And sorry about the typo in my first post. Hopefully the text explained what I wanted to do...

I tested your suggestion. Little typo here too: should be new1 instead of old2 in the first rule ;-)

I had to modify for my case. The redirect leads to domain.com/var/www/user/html/new, thus I put a / before new to let it work.

Code: Select all
RewriteRule ^old$ /new [L,R=301]

Thank you for your patience and help :)
knut
 
Posts: 7
Joined: Thu Mar 07, 2013 2:38 pm

Re: redirect old pages

Postby hansfn » Tue Jun 24, 2014 7:17 pm

I fixed the typo above (in my example).

The reason you needed to add a slash is that you haven't set RewriteBase (to "/") - the line that is commented out in example.htaccess.
hansfn
Developer
 
Posts: 3282
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway


Return to 2.x Support Forum

Who is online

Users browsing this forum: No registered users and 3 guests

cron