View Full Version : 301 Redirect: Page to Directory
ResaleBroker
Jan 3rd 2005, 11:21 am
I just noticed I have a few different URL's out there to one of my forums.
http://www.google.com/search?q=allintitle:arizona+real+estate+forum-resalebroker&hl=en&lr=&filter=0
1. forum/
2. forum/index
3. forum/index.php?
I want to redirect URLs two (2) and three(3) to URL one (1).
I've tried this mod_rewrite but it doesn't work:
RewriteRule ^real-estate-forum/index(.*) http://www.resalebroker.com/real-estate-forum/ [L,R=301]
Anybody have an idea of how to make this work?
Will.Spencer
Jan 3rd 2005, 1:27 pm
How about using this in your .htaccess file this instead of using mod_rewrite:
Redirect 301 forum/index http://www.resalebroker.com/real-estate-forum/
Redirect 301 forum/index.php? http://www.resalebroker.com/real-estate-forum/
ResaleBroker
Jan 3rd 2005, 2:04 pm
That works with the "index" but not the "index.php" and I do not know why.
I'm going to have to do some checking into my vBulletin set up. Maybe there is already a redirect in place that I'm not aware of.
J.D.
Jan 3rd 2005, 4:49 pm
That works with the "index" but not the "index.php" and I do not know why.
The correct syntax is
Redirect [status] URL-path URL
Lose the question mark.
J.D.
ResaleBroker
Jan 3rd 2005, 4:52 pm
Hi J.D.,
I can get the redirect to work without the question mark. Any ideas on how to get it to work with the question mark?
OR... does anyone know how to modify vBulletin URLs to remove the question mark? That is where it's coming from.
J.D.
Jan 3rd 2005, 5:07 pm
I can get the redirect to work without the question mark. Any ideas on how to get it to work with the question mark?
It already is working :) When a visitor requests
website.com/index.php?arg=value&arg=value
Apache matches the URL path (i.e. /index.php) and redirects the request to the new URL, keeping the query string:
website.com/?arg=value&arg=value
This is from the Apache docs:
The Redirect directive maps an old URL into a new one. The new URL is returned to the client which attempts to fetch it again with the new address. URL-path a (%-decoded) path; any requests for documents beginning with this path will be returned a redirect error to a new (%-encoded) URL beginning with URL.
J.D.
J.D.
Jan 3rd 2005, 5:12 pm
Redirect 301 forum/index.php? http://www.resalebroker.com/real-estate-forum/
BTW, according to Apache docs, URL-path (i.e. forum/index.php) *must* be prefixed with a slash.
J.D.
ResaleBroker
Jan 3rd 2005, 7:30 pm
BTW, according to Apache docs, URL-path (i.e. forum/index.php) *must* be prefixed with a slash.Yeah, I nipped it in the bud when typing in the code.
I can get the redirect to work without the question mark.My mind must be fried. I can't remember how I got that to work. You would think that this would work but it doesn't:
Redirect 301 /real-estate-forum/index.php http://www.resalebroker.com/real-estate-forum/
Right now I would be happy with just getting the index.php to redirect to forum/. Any ideas?
J.D.
Jan 3rd 2005, 8:04 pm
Redirect 301 /real-estate-forum/index.php http://www.resalebroker.com/real-estate-forum/
Right now I would be happy with just getting the index.php to redirect to forum/. Any ideas?
There's something very wrong with your setup - your server redirects *every* request to the *same* URL. Most likely you have
Redirect 301 / ...
somewhere in your configuration. You need to fix this asap - some browsers may get into a loop trying to follow the same link over and over again. Search your main config and any .htaccess files you may have for out-of-place Redirect's.
J.D.
ResaleBroker
Jan 3rd 2005, 9:17 pm
J.D., when you say "every" request what do you mean?
J.D.
Jan 3rd 2005, 9:38 pm
J.D., when you say "every" request what do you mean?
If I request /test-url, here's what I get back (I removed a couple of lines for simplicity):
HTTP/1.1 301 Moved Permanently
Date: Tue, 04 Jan 2005 05:32:55 GMT
Location: http://www.resalebroker.com/test-url
Content-Type: text/html; charset=iso-8859-1
The highlighted is the redirection header. As far as I can see, it points to the same server and the same URL. I have seen IE in the past chew up bandwidth trying to retrieve such URLs over and over again. It doesn't seem to happen now, but there could be some other dumb browser that does just that.
J.D.
ResaleBroker
Jan 3rd 2005, 9:50 pm
Where are you seeing that?
J.D.
Jan 3rd 2005, 9:52 pm
Where are you seeing that?
That's a response I get back from www.resalebroker.com.
J.D.
ResaleBroker
Jan 3rd 2005, 9:54 pm
I just checked here and I am not getting that server response:
http://www.seologic.com/webmaster-tools/url-redirect.php
J.D.
Jan 3rd 2005, 10:03 pm
I just checked here and I am not getting that server response:
http://www.seologic.com/webmaster-tools/url-redirect.php
That's a different website, isn't it (there's nothing wrong with this one, btw). The response I quoted was from the one you mentioned in the original post - www.resalebroker.com.
J.D.
ResaleBroker
Jan 3rd 2005, 10:06 pm
This is what I get:
Server Response : www.resalebroker.com
HTTP/1.1 200 OK
Date: Tue, 04 Jan 2005 06:06:20 GMT
Server: Apache/1.3.31 (Unix) PHP/4.3.10 mod_ssl/2.8.18 OpenSSL/0.9.6b FrontPage/5.0.2.2635 mod_throttle/3.1.2
J.D.
Jan 3rd 2005, 10:14 pm
This is what I get:
Server Response : www.resalebroker.com
HTTP/1.1 200 OK
Date: Tue, 04 Jan 2005 06:06:20 GMT
Server: Apache/1.3.31 (Unix) PHP/4.3.10 mod_ssl/2.8.18 OpenSSL/0.9.6b FrontPage/5.0.2.2635 mod_throttle/3.1.2
Just checked for HTTP/1.0 and HTTP/1.1 - same result. Here's the complete response header:
HTTP/1.1 301 Moved Permanently
Date: Tue, 04 Jan 2005 06:10:27 GMT
Server: Apache/1.3.31 (Unix) PHP/4.3.10 mod_ssl/2.8.18 OpenSSL/0.9.6b FrontPage/5.0.2.2635 mod_throttle/3.1.2
Location: http://www.resalebroker.com/test-url
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1
The IP address I'm hitting: 64.17.136.90. Can it be that mod_rewrite is getting in the way?
J.D.
ResaleBroker
Jan 3rd 2005, 10:21 pm
The IP address I'm hitting: 64.17.136.90. Can it be that mod_rewrite is getting in the way?You had me going there for a minute. :eek:
That IP address points to http://resalebroker.com and yes I have used a mod_rewrite to redirect it to http://www.resalebroker.com
Now if I could just figure out that darn redirect for forum/index.php :p
J.D.
Jan 3rd 2005, 10:39 pm
That IP address points to http://resalebroker.com and yes I have used a mod_rewrite to redirect it to http://www.resalebroker.com
I did connect to www.resalebroker.com, not resalebroker.com. My guess is that you have www.resalebroker.com set up as a virtual website then and the redirect kicks in if there's no Host header (btw, you could use DNS instead - would be faster).
Now if I could just figure out that darn redirect for forum/index.php :p
This one should be simple - just check your configuration step by step. Both Apache 1.3 and 2.0 behave the same way with regards to Redirect and the only thing I can think of is some kind of a typo or conflicting configuration.
J.D.
ResaleBroker
Jan 3rd 2005, 10:44 pm
I removed the mod_rewrite to test the server response and it came back HTTP/1.1 200 OK [64.17.136.90]. As soon as I put put the mod_rewrite back I got the HTTP/1.1 301 Moved Permanently.
I'm thinking there must be something with the vBulletin software that I'm not aware of. The guy who set that forum up for me knows it inside and out so I'm hoping he can point me in the right direction. [fingers crossed]
J.D.
Jan 3rd 2005, 10:49 pm
I removed the mod_rewrite to test the server response and it came back HTTP/1.1 200 OK [64.17.136.90]. As soon as I put put the mod_rewrite back I got the HTTP/1.1 301 Moved Permanently.
I just double-checked it. Your website returns 301 if the Host header isn't www.resalebroker.com. This must be done with mod_rewrite. I guess here's your problem then :)
J.D.
ResaleBroker
Jan 3rd 2005, 10:52 pm
That doesn't seem like a problem to me. I want everything going through [w]ww.resalebroker.com.
J.D.
Jan 3rd 2005, 11:02 pm
That doesn't seem like a problem to me. I want everything going through [w]ww.resalebroker.com.
I meant with regards to your initial redirect problem. I'm not sure which one has priority (mod_rewrite or mod_alias).
J.D.
ResaleBroker
Jan 3rd 2005, 11:05 pm
hmmm... good question.:)
J.D.
Jan 3rd 2005, 11:49 pm
BTW, if you just want to alias resalebroker.com as www.resalebroker.com, you could just use ServerAlias. This way you wouldn't need to scan requests (not at least for this purpose) and there wouldn't be any need for an extra redirect.
J.D.
ResaleBroker
Jan 4th 2005, 6:31 am
I'll check it out. Thanks!
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.