Page 1 of 1

.htaccess file redirects give servererror 500

Posted: Mon Apr 18, 2011 4:34 pm
by Gasoline
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.

Re: .htaccess file redirects give servererror 500

Posted: Tue May 03, 2011 3:03 pm
by Gasoline
ANYBODY !!!!!!!! ???

Re: .htaccess file redirects give servererror 500

Posted: Tue May 03, 2011 8:53 pm
by g1smd
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.

Re: .htaccess file redirects give servererror 500

Posted: Wed May 04, 2011 8:01 am
by Gasoline
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]

Re: .htaccess file redirects give servererror 500

Posted: Wed May 04, 2011 8:12 am
by g1smd
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: Select all

########## 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.

Re: .htaccess file redirects give servererror 500

Posted: Wed May 04, 2011 8:44 am
by Gasoline
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.

Re: .htaccess file redirects give servererror 500

Posted: Wed May 04, 2011 8:47 am
by g1smd
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.

Re: .htaccess file redirects give servererror 500

Posted: Wed May 04, 2011 8:54 am
by Gasoline
I already use the htaccessfile from Joomla. So I added the redirects in that file after:

## Begin - Custom redirects

Re: .htaccess file redirects give servererror 500

Posted: Wed May 04, 2011 9:18 am
by g1smd
Yep. That's the right place. :)

Re: .htaccess file redirects give servererror 500

Posted: Thu May 05, 2011 7:49 am
by Gasoline
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.

Re: .htaccess file redirects give servererror 500

Posted: Thu May 05, 2011 7:54 am
by g1smd
The whole site or one particular page?

Does it work on other PCs and other devices?

Re: .htaccess file redirects give servererror 500

Posted: Thu May 05, 2011 8:14 am
by Gasoline
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?