0

Trying to do something simple here, but having a great deal of difficulty

.htaccess

Redirect 301 /foo-bar /foobar

This works on OSX but CentOS complains that I'm not using a full URL.

CentOS wants

Redirect 301 /foo-bar http://example.com/foobar

I don't want to specify the the full host name for each URL.

Both OSX and CentOS are running Apache 2.2.x

Is there some way to accomplish this?


Update:

I've tried RewriteRule and it doesn't even seem to work

RewriteEngine On
RewriteRule ^/foo-bar$ /foobar [R=301,L]

The match isn't even made and now I'm getting a 404 error

1 Answer 1

0

Apparently apache doesn't support relative urls in the target of a Redirect until 2.2.6

My CentOS is running 2.2.3 so that's was the problem there


My attempt at using RewriteRule was also incorrect. The following will work as intended

RewriteEngine On
RewriteRule ^foo-bar$ /foobar [R=301,L]

Note the leading / is removed from my original question


Long story short, you can use Redirect with relative urls if your apache is >= 2.2.6

Redirect 301 /foo-bar /foobar

Or use RewriteRule if you are stuck on an older version

RewriteEngine On
RewriteRule ^foo-bar$ /foobar [R=301,L]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .