.htaccess file redirects give servererror 500

General questions relating to Joomla! 2.5. Note: All 1.6 and 1.7 releases have reached end of life and should be updated to 2.5. There are other boards for more specific help on Joomla! features and extensions.

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.
Locked
User avatar
Gasoline
Joomla! Explorer
Joomla! Explorer
Posts: 468
Joined: Tue Aug 23, 2005 10:33 am
Location: NL

.htaccess file redirects give servererror 500

Post by Gasoline » Mon Apr 18, 2011 4:34 pm

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.
Using Joomla since 2005.

User avatar
Gasoline
Joomla! Explorer
Joomla! Explorer
Posts: 468
Joined: Tue Aug 23, 2005 10:33 am
Location: NL

Re: .htaccess file redirects give servererror 500

Post by Gasoline » Tue May 03, 2011 3:03 pm

ANYBODY !!!!!!!! ???
Using Joomla since 2005.

g1smd
Joomla! Guru
Joomla! Guru
Posts: 951
Joined: Mon Feb 21, 2011 4:02 pm
Location: UK

Re: .htaccess file redirects give servererror 500

Post by g1smd » Tue May 03, 2011 8:53 pm

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.

User avatar
Gasoline
Joomla! Explorer
Joomla! Explorer
Posts: 468
Joined: Tue Aug 23, 2005 10:33 am
Location: NL

Re: .htaccess file redirects give servererror 500

Post by Gasoline » Wed May 04, 2011 8:01 am

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]
Using Joomla since 2005.

g1smd
Joomla! Guru
Joomla! Guru
Posts: 951
Joined: Mon Feb 21, 2011 4:02 pm
Location: UK

Re: .htaccess file redirects give servererror 500

Post by g1smd » Wed May 04, 2011 8:12 am

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.
Online since 1995.

User avatar
Gasoline
Joomla! Explorer
Joomla! Explorer
Posts: 468
Joined: Tue Aug 23, 2005 10:33 am
Location: NL

Re: .htaccess file redirects give servererror 500

Post by Gasoline » Wed May 04, 2011 8:44 am

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.
Using Joomla since 2005.

g1smd
Joomla! Guru
Joomla! Guru
Posts: 951
Joined: Mon Feb 21, 2011 4:02 pm
Location: UK

Re: .htaccess file redirects give servererror 500

Post by g1smd » Wed May 04, 2011 8:47 am

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.

User avatar
Gasoline
Joomla! Explorer
Joomla! Explorer
Posts: 468
Joined: Tue Aug 23, 2005 10:33 am
Location: NL

Re: .htaccess file redirects give servererror 500

Post by Gasoline » Wed May 04, 2011 8:54 am

I already use the htaccessfile from Joomla. So I added the redirects in that file after:

## Begin - Custom redirects
Using Joomla since 2005.

g1smd
Joomla! Guru
Joomla! Guru
Posts: 951
Joined: Mon Feb 21, 2011 4:02 pm
Location: UK

Re: .htaccess file redirects give servererror 500

Post by g1smd » Wed May 04, 2011 9:18 am

Yep. That's the right place. :)
Online since 1995.

User avatar
Gasoline
Joomla! Explorer
Joomla! Explorer
Posts: 468
Joined: Tue Aug 23, 2005 10:33 am
Location: NL

Re: .htaccess file redirects give servererror 500

Post by Gasoline » Thu May 05, 2011 7:49 am

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.
Using Joomla since 2005.

g1smd
Joomla! Guru
Joomla! Guru
Posts: 951
Joined: Mon Feb 21, 2011 4:02 pm
Location: UK

Re: .htaccess file redirects give servererror 500

Post by g1smd » Thu May 05, 2011 7:54 am

The whole site or one particular page?

Does it work on other PCs and other devices?
Online since 1995.

User avatar
Gasoline
Joomla! Explorer
Joomla! Explorer
Posts: 468
Joined: Tue Aug 23, 2005 10:33 am
Location: NL

Re: .htaccess file redirects give servererror 500

Post by Gasoline » Thu May 05, 2011 8:14 am

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?
Using Joomla since 2005.


Locked

Return to “General Questions/New to Joomla! 2.5”