View Full Version : 301 Redirect a vbulletin thread?
Infiniterb
Mar 2nd 2005, 10:00 pm
Would the following work?
redirect 301 http://www.domain.com/vb/showthread.php?t=1234 http://www.domain.com/subdirectory/
If not, how would I redirect this? Also, does the redirect need to be in the root directory, or under the vb directory?
Infiniterb
Mar 2nd 2005, 10:12 pm
Hmm, nevermind, I figured it out.
redirect 301 /vb/showthread.php?t=1234 http://www.domain.com/subdirectory/
Needs to be like that on the root .htaccess file. However, I now get http://www.domain.com/subdirectory/ with the ?t=1234 appended to the new url. Any ideas?
J.D.
Mar 2nd 2005, 10:14 pm
Needs to be like that on the root .htaccess file. However, I now get http://www.domain.com/subdirectory/ with the ?t=1234 appended to the new url. Any ideas?This is how redirect is supposed to work - the first argument is supposed to be a path, not a URL. You need to use mod_rewrite instead.
J.D.
Infiniterb
Mar 2nd 2005, 10:58 pm
Yeah, I figured the first part out about it needing to be a path and not the actual url. Thanks though.
What's getting me now is that when I click on my link I get redirected, but the url in the address bar is now:
http://www.domain.com/subdirectory/index.html?t=1234
If possible, I'd like to eliminate the ? at the end. Any idea?
J.D.
Mar 3rd 2005, 7:52 am
What's getting me now is that when I click on my link I get redirected, but the url in the address bar is now:
http://www.domain.com/subdirectory/index.html?t=1234
If possible, I'd like to eliminate the ? at the end. Any idea?As I mentioned, you need to use mod_rewrite. Since you didn't define the logic you use to arrive at subdirectory from the original path, I can't give you an example, but you should find plenty examples on rewriting URLs in this forum. Just search for RewriteRule. Here's the link to Apache's rewrite guide:
http://httpd.apache.org/docs-2.0/misc/rewriteguide.html
J.D.
Infiniterb
Mar 3rd 2005, 10:22 am
Ah, I see. Read the guide but still not seeing what I need to.
Thanks for the help though. I do appreciate it.
J.D.
Mar 3rd 2005, 11:07 am
Well, you need to come up with some logic how to transform the original URL into a new one. For example, if you do something like this:
RewriteRule ^some-path/([0-9]+)/([0-9]+)/?$ /my.php?id=$1&v2=$2
you could serve URLs that look like /some-path/5/10 as /my-php?id=5&v=10.
With mod_rewrite, you can also redirect URLs - if the first expression matches, redirect to a new URL, composed out of parts of the original one.
J.D.
Infiniterb
Mar 3rd 2005, 11:14 am
Yeah, I tried multiple methods, and was getting 500 internal errors.
The url just needs to change from path/index.html?t=6740 to path/index.html. I just need to stip out the ?t=6740 (that number exactly). There will be no other ?t=xxxx number since the 301 redirect is leaving that in the url for some reason.
I had tried:
RewriteRule ^some-path/index.html$ /some-path/index.html?t=6740
And was getting 500 errors. I tried adding [R], got a 500. Tried [L] and it worked, but the url was still using ?t=6740.
J.D.
Mar 3rd 2005, 11:57 am
try this:
RewriteRule ^some-path/index.html\?t=6740$ /some-path/index.html
If you need parts of the original path, use parenthesis and $n params. For example:
RewriteRule ^([a-z0-9]+)/index.html\?t=6740$ /$1/index.html
J.D.
Infiniterb
Mar 3rd 2005, 1:04 pm
Hmm, that still didn't work. I'll PM you what I'm working with so you can see the "problem" in action.
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.