1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

301 Redirect: Page to Directory

Discussion in 'Apache' started by ResaleBroker, Jan 3, 2005.

  1. #1
    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?
     
    ResaleBroker, Jan 3, 2005 IP
  2. Will.Spencer

    Will.Spencer NetBuilder

    Messages:
    14,789
    Likes Received:
    1,040
    Best Answers:
    0
    Trophy Points:
    375
    #2
    How about using this in your .htaccess file this instead of using mod_rewrite:

    Code (Text):
    1.  
    2. Redirect 301 forum/index                 [url]http://www.resalebroker.com/real-estate-forum/[/url]
    3. Redirect 301 forum/index.php?          [url]http://www.resalebroker.com/real-estate-forum/[/url]
    4.  
     
    Will.Spencer, Jan 3, 2005 IP
  3. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #3
    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.
     
    ResaleBroker, Jan 3, 2005 IP
  4. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The correct syntax is

    Code (Text):
    1.  
    2. Redirect [status] URL-path URL
    3.  
    Lose the question mark.

    J.D.
     
    J.D., Jan 3, 2005 IP
  5. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #5
    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.
     
    ResaleBroker, Jan 3, 2005 IP
  6. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #6
    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:

    J.D.
     
    J.D., Jan 3, 2005 IP
  7. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #7
    BTW, according to Apache docs, URL-path (i.e. forum/index.php) *must* be prefixed with a slash.

    J.D.
     
    J.D., Jan 3, 2005 IP
  8. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #8
    Yeah, I nipped it in the bud when typing in the code.

    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?
     
    ResaleBroker, Jan 3, 2005 IP
  9. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #9
    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.
     
    J.D., Jan 3, 2005 IP
  10. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #10
    J.D., when you say "every" request what do you mean?
     
    ResaleBroker, Jan 3, 2005 IP
  11. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #11
    If I request /test-url, here's what I get back (I removed a couple of lines for simplicity):

    Code (Text):
    1. HTTP/1.1 301 Moved Permanently
    2. Date: Tue, 04 Jan 2005 05:32:55 GMT
    3. [b]Location: http://www.resalebroker.com/test-url[/b]
    4. Content-Type: text/html; charset=iso-8859-1
    5.  
    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.
     
    J.D., Jan 3, 2005 IP
  12. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #12
    Where are you seeing that?
     
    ResaleBroker, Jan 3, 2005 IP
  13. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #13
    That's a response I get back from www.resalebroker.com.

    J.D.
     
    J.D., Jan 3, 2005 IP
  14. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #14
    ResaleBroker, Jan 3, 2005 IP
  15. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #15
    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.
     
    J.D., Jan 3, 2005 IP
  16. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #16
    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
     
    ResaleBroker, Jan 3, 2005 IP
  17. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Just checked for HTTP/1.0 and HTTP/1.1 - same result. Here's the complete response header:

    Code (Text):
    1. HTTP/1.1 301 Moved Permanently
    2. Date: Tue, 04 Jan 2005 06:10:27 GMT
    3. 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
    4. Location: http://www.resalebroker.com/test-url
    5. Connection: close
    6. Transfer-Encoding: chunked
    7. 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.
     
    J.D., Jan 3, 2005 IP
  18. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #18
    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://[COLOR=Red]www[/COLOR].resalebroker.com

    Now if I could just figure out that darn redirect for forum/index.php :p
     
    ResaleBroker, Jan 3, 2005 IP
  19. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #19
    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).

    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.
     
    J.D., Jan 3, 2005 IP
  20. ResaleBroker

    ResaleBroker Active Member

    Messages:
    1,665
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    90
    #20
    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]
     
    ResaleBroker, Jan 3, 2005 IP