mgm_03
October 23, 2008, 5:17pm
1
We’re on Apache and when I insert a handful of 301 redirect statements, the 500 internal server error comes up.
Example:
Redirect 301 /products/tech.html /products/technology.html
It doesn’t matter if I used the absolute URL or not for the new destination.
sparek
October 23, 2008, 6:53pm
2
You say that you are inserting a handful. What happens if you just insert one?
You may have a syntax error in one of the lines that you are inserting.
You can also check the Apache error log for more information.
mgm_03
October 23, 2008, 7:06pm
3
When I only use one, I get the same result.
sparek
October 23, 2008, 7:12pm
4
What does the Apache error log show when you encounter this error?
SariJ
October 24, 2008, 3:02am
5
Is RewriteEngine kept On and hope the .htaccess is enabled via the apache conf with the AllowOverride All variable?
SergHZ
October 24, 2008, 6:45am
6
Make sure that Apache is compiled with mod_rewrite module on your server. Otherwise you will get an Internal Server error when you use rewrite rules.
dklynn
October 25, 2008, 5:58am
7
HZ: Really? Redirect is mod_alias (Apache core) and mod_rewrite has NOTHING to do with it! PLEASE don’t scare me like this - I have my (VPS) account there!
mgm: I suspect that sparek is correct - that you have a syntax error in your Redirect statement(s)
http://httpd.apache.org/docs/2.0/mod/mod_alias.html#redirect:
Redirect Directive
Description: Sends an external redirect asking the client to fetch a different URL
Syntax: Redirect [status] URL-path URL
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Base
Module: mod_alias
The Redirect directive maps an old URL into a new one by asking the client to refetch the resource at the new location.
The old URL-path is a case-sensitive (%-decoded) path beginning with a slash. A relative path is not allowed. The new URL should be an absolute URL beginning with a scheme and hostname.
Example:
Redirect /service http://foo2.bar.com/service
If the client requests http://myserver/service/foo.txt , it will be told to access http://foo2.bar.com/service/foo.txt instead.
Note
Redirect directives take precedence over Alias and ScriptAlias directives, irrespective of their ordering in the configuration file. Also, URL-path must be a fully qualified URL, not a relative path, even when used with .htaccess files or inside of <Directory> sections.
If no status argument is given, the redirect will be “temporary” (HTTP status 302). This indicates to the client that the resource has moved temporarily. The status argument can be used to return other HTTP status codes:
permanent
Returns a permanent redirect status (301) indicating that the resource has moved permanently.
temp
Returns a temporary redirect status (302). This is the default.
seeother
Returns a “See Other” status (303) indicating that the resource has been replaced.
gone
Returns a “Gone” status (410) indicating that the resource has been permanently removed. When this status is used the URL argument should be omitted.
Other status codes can be returned by giving the numeric status code as the value of status. If the status is between 300 and 399, the URL argument must be present, otherwise it must be omitted. Note that the status must be known to the Apache code (see the function send_error_response in http_protocol.c).
Example:
Redirect permanent /one http://example.com/two
Redirect 303 /three http://example.com/other
Your use of 301 is correct and the internal version of an absolute URI is acceptable, too. Given only the one Redirect statement (which appears correctly formatted), I don’t know what the problem is. Care to post the entire set - better yet, the entire .htaccess this is in?
Regards,
DK
SergHZ
October 27, 2008, 6:14am
8
That’s correct Redirect is mod_alias. What Apache error log throws when you get this error. It will help us to tell you what might be a problem.