.htaccess file redirects give servererror 500
Moderator: General Support Moderators
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.
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.
- Gasoline
- Joomla! Explorer
- Posts: 468
- Joined: Tue Aug 23, 2005 10:33 am
- Location: NL
.htaccess file redirects give servererror 500
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.
What I did was:
redirect 301 /oldpage.html http://www.website.nl/newpage
Please help.
Using Joomla since 2005.
- Gasoline
- Joomla! Explorer
- Posts: 468
- Joined: Tue Aug 23, 2005 10:33 am
- Location: NL
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: .htaccess file redirects give servererror 500
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.
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.
- Gasoline
- Joomla! Explorer
- Posts: 468
- Joined: Tue Aug 23, 2005 10:33 am
- Location: NL
Re: .htaccess file redirects give servererror 500
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.
Thanks, this works like a charme.
Directly after Rewrite engine on line:
RewriteRule ^pagename.html$ http://www.domain.nl/newpagename [R=301,L]
Using Joomla since 2005.
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: .htaccess file redirects give servererror 500
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.
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.
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
Online since 1995.
- Gasoline
- Joomla! Explorer
- Posts: 468
- Joined: Tue Aug 23, 2005 10:33 am
- Location: NL
Re: .htaccess file redirects give servererror 500
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.
Anyway, thanks for your support. This was great.
Using Joomla since 2005.
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: .htaccess file redirects give servererror 500
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.
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.
- Gasoline
- Joomla! Explorer
- Posts: 468
- Joined: Tue Aug 23, 2005 10:33 am
- Location: NL
Re: .htaccess file redirects give servererror 500
I already use the htaccessfile from Joomla. So I added the redirects in that file after:
## Begin - Custom redirects
## Begin - Custom redirects
Using Joomla since 2005.
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
- Gasoline
- Joomla! Explorer
- Posts: 468
- Joined: Tue Aug 23, 2005 10:33 am
- Location: NL
Re: .htaccess file redirects give servererror 500
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.
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.
Using Joomla since 2005.
-
- Joomla! Guru
- Posts: 951
- Joined: Mon Feb 21, 2011 4:02 pm
- Location: UK
Re: .htaccess file redirects give servererror 500
The whole site or one particular page?
Does it work on other PCs and other devices?
Does it work on other PCs and other devices?
Online since 1995.
- Gasoline
- Joomla! Explorer
- Posts: 468
- Joined: Tue Aug 23, 2005 10:33 am
- Location: NL
Re: .htaccess file redirects give servererror 500
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?
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?
Using Joomla since 2005.