The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.



Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Mon Apr 18, 2011 4:34 pm 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Tue Aug 23, 2005 10:33 am
Posts: 379
Location: NL
I wanted to place some rewdirects in htaccessfile because site is gone live today (old urls need te be redirected). But I get a error 500. What Am I doing wrong. Om other (j1.5) sites it works. But not on this 1.6.1 site.

What I did was:
redirect 301 /oldpage.html http://www.website.nl/newpage

Please help.

_________________
http://joomlatips.nl


Top
 Profile  
 
PostPosted: Tue May 03, 2011 3:03 pm 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Tue Aug 23, 2005 10:33 am
Posts: 379
Location: NL
ANYBODY !!!!!!!! ???

_________________
http://joomlatips.nl


Top
 Profile  
 
PostPosted: Tue May 03, 2011 8:53 pm 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
Use RewriteRule, not Redirect.

Use the [R=301,L] flags on the rule.

Make sure the new redirect code is placed soon after the RewriteEngine On line.

_________________
Online since 1995.


Top
 Profile  
 
PostPosted: Wed May 04, 2011 8:01 am 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Tue Aug 23, 2005 10:33 am
Posts: 379
Location: NL
g1smd wrote:
Use RewriteRule, not Redirect.

Use the [R=301,L] flags on the rule.

Make sure the new redirect code is placed soon after the RewriteEngine On line.



:pop :pop :pop :pop :pop :pop :) :) :) :)

Thanks, this works like a charme.


Directly after Rewrite engine on line:

RewriteRule ^pagename.html$ http://www.domain.nl/newpagename [R=301,L]

_________________
http://joomlatips.nl


Top
 Profile  
 
PostPosted: Wed May 04, 2011 8:12 am 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
One small change, make pagename.html into pagename\.html.

In the RegEx pattern, the period means ANY character. So pagename.html in the pattern would also match a request for pagenameXhtml or pagename8html and so on.

The period in the RegEx pattern is the only one that needs escaping. Do not escape anything in the literal target URL.

You might want to add a standard set of domain canonicalisation rules after your new rule. Change example.com to match your domain name. Take care to use \. and . in the right places.
Code:
########## Begin - 301 Redirect
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|home)\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|home)\.html?$ http://www.example.com/$1 [R=301,L]
#
RewriteCond %{THE_REQUEST} !^POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(([^/]+/)*)index\.php$ http%2://www.example.com/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
########## End - 301 Redirect

I urge you to use the new .htaccess file that comes with Joomla 1.5.23 onwards or Joomla 1.6.2 onwards. Look for the file called htaccess.txt in the installer package. It contains a note showing exactly where the redirects should go (in addition to a number of other changes). Add your new redirect code in the file at the point it says "redirects go here", or similar. The new file works with all older versions of Joomla.

_________________
Online since 1995.


Top
 Profile  
 
PostPosted: Wed May 04, 2011 8:44 am 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Tue Aug 23, 2005 10:33 am
Posts: 379
Location: NL
I only have to redirect certain .html pages. I build a new site with J1.6. Old site was not Joomla. So I think I don't need the \ thing in the lines.

Anyway, thanks for your support. This was great.

_________________
http://joomlatips.nl


Top
 Profile  
 
PostPosted: Wed May 04, 2011 8:47 am 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
Yes, you need the \. in the RegEx pattern to ensure that that part of the RegEx pattern matches only a literal period in the request.

If you put just a period, without escaping it, then that means "any character". You don't want "any character". You want "literial period".

Characters that have a special meaning within the RegEx syntax must be escaped when you want that character to assume its literal meaning in a RegEx pattern.

_________________
Online since 1995.


Top
 Profile  
 
PostPosted: Wed May 04, 2011 8:54 am 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Tue Aug 23, 2005 10:33 am
Posts: 379
Location: NL
I already use the htaccessfile from Joomla. So I added the redirects in that file after:

## Begin - Custom redirects

_________________
http://joomlatips.nl


Top
 Profile  
 
PostPosted: Wed May 04, 2011 9:18 am 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
Yep. That's the right place. :)

_________________
Online since 1995.


Top
 Profile  
 
PostPosted: Thu May 05, 2011 7:49 am 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Tue Aug 23, 2005 10:33 am
Posts: 379
Location: NL
Hi,

Client complains that is site is not working anymore in his iPad2. Is this because of this change?
Or is this (again) a stupid client remark.

_________________
http://joomlatips.nl


Top
 Profile  
 
PostPosted: Thu May 05, 2011 7:54 am 
Joomla! Guru
Joomla! Guru

Joined: Mon Feb 21, 2011 4:02 pm
Posts: 951
Location: UK
The whole site or one particular page?

Does it work on other PCs and other devices?

_________________
Online since 1995.


Top
 Profile  
 
PostPosted: Thu May 05, 2011 8:14 am 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Tue Aug 23, 2005 10:33 am
Posts: 379
Location: NL
It works on my PC's ;-).

I assume his iPad was mailfunctioning, but the only thing I changed yesterday (done nothing rest of the week) was .htaccess file. But I can't imagine it's that.

[EDIT]
Checked it with Safari (developer mode iPad). But site isn't working with or without htaccess changes. ;-(

Maybe site stopped working on iPad because client doesn't want to pay the whole invoice?

_________________
http://joomlatips.nl


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 



Who is online

Users browsing this forum: Alexa [Bot], Google [Bot] and 34 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group