.htaccess redirect problems


#1

Hi. I’m trying to create a .htaccess redirect rule to direct all traffic entering the root of my site to direct to a subdirectory. I tried this:

Redirect 301 / http://www.mydomain.com/phpBB

But, when I go to the root of my site, I get an error saying the site isn’t redirecting properly. If I look in the address bar, it looks like this:

http://www.mydomain.com/phpBB/phpBB/phpBB/phpBB/phpBB/phpBB/

How can I fix this?


#2

[quote]Hi. I’m trying to create a .htaccess redirect rule to direct all traffic entering the root of my site to direct to a subdirectory. I tried this:

Redirect 301 / http://www.mydomain.com/phpBB

But, when I go to the root of my site, I get an error saying the site isn’t redirecting properly. If I look in the address bar, it looks like this:

http://www.mydomain.com/phpBB/phpBB/phpBB/phpBB/phpBB/phpBB/

How can I fix this?[/quote]
It can be fixed by reading the documentation carefully and using RedirectMatch instead.

:cool: openvein.org -//- One-time [color=#6600CC]$50.00 discount[/color] on [color=#0000CC]DreamHost[/color] plans: Use ATROPOS7


#3

Where can I find this documentation? I don’t know exactly what to search for which is why I came here.


#4

For starters, putting the words “documentation” and “redirectmactch” into Google (no quotes) provides some interesting results (like the apache manual, where all this stuff is discussed). :wink:

–rlparker


#5

I’ll go ahead and clarify now.

Redirect is meant for matching URLs that begin with the same string. It is not designed to match a string exactly. For example your url-path is /something.htm and someone tries to visit /something.html - they will get redirected.

Obviously you need something that can match a string exactly. And that is where RedirectMatch comes in. You can use it to match URLs that begin and end with a certain string:

RedirectMatch ^/$ /forum/

Where the regular expression indicates we are looking for a URL that begins with a slash, contains only a slash, and ends with a slash.

So don’t forget to bookmark Apache HTTP Server Documentation

:cool: openvein.org -//- One-time [color=#6600CC]$50.00 discount[/color] on [color=#0000CC]DreamHost[/color] plans: Use ATROPOS7