XF 1.5 redirection scripts won't work on SSL

Im using the redirection scrips for vbulletin and recently moved my forum to SSL, but now a lot of links won't redirect like they should.

As you can see the urls go from http to https, and back to http, and again to https. So, Im concerned that it may hurt my google page rank, because the external backlinks are "leaking authority". (due to multiple redirections)

This type of URL works, but Im getting a lot of redirections:

http://www.site.com/forums/showthread.php?t=212121 > https://www.site.com/forums/showthread.php?t=212121 > http://www.site.com/showthread.php?t=212121 > https://www.site.com/showthread.php?t=212121 > https://www.site.com/threads/212121/

Also this type of URL won't get redirected and it goes to the main site instead of the thread ID, but in the process it "jumps" 4 times:

http://www.site.com/forums/showthread.php?8824 > https://www.site.com/forums/showthread.php?8824 > http://www.site.com/showthread.php?8824 > https://www.site.com/showthread.php?8824 > https://www.site.com

I would really appreciate any help, I tried to add a few rewrite rules to the htaccess but none of them work.
 
Last edited:
I was trying to redirect this URL

http://www.site.com/forums/showthread.php?8824

to this URL:

https://www.site.com/forums/test-example.8824/

So, I added this code to the htaccess :

Code:
RewriteEngine On

RewriteCond %{QUERY_STRING} (^|\?|&)p=([0-9]+)($|&)
RewriteRule ^showthread\.php$ /posts/%2/? [R=301,L]
RewriteCond %{QUERY_STRING} (^|\?)([0-9]+)-[^/]+/page([0-9]+)$
RewriteRule ^showthread\.php$ /threads/%2/page-%3? [R=301,L]
RewriteCond %{QUERY_STRING} (^|\?)([0-9]+)-.*$
RewriteRule ^showthread\.php$ /threads/%2/? [R=301,L]

I even tried this:

Code:
RewriteEngine On

# post redirect
RewriteCond %{QUERY_STRING} (^|&|\?)p=([0-9]+)($|&)
RewriteRule ^showthread\.php$ /forums/posts/%2/? [R=301,L]
# thread redirect
RewriteCond %{QUERY_STRING} (^|\?)([0-9]+)$
RewriteRule ^showthread\.php$ /forums/threads/%2/? [R=301,L]

But It doesn't work... :/ I really need some help.
 
Last edited:
ok this solves that problem :

Code:
# post redirect
RewriteCond %{QUERY_STRING} (^|&|\?)p=([0-9]+)($|&)
RewriteRule ^forums/showthread\.php$ /posts/%2/? [R=301,L]
# thread redirect
RewriteCond %{QUERY_STRING} (^|\?)([0-9]+)$
RewriteRule ^forums/showthread\.php$ /threads/%2/? [R=301,L]

But how do I redirect a thread from http to https avoiding too many "jumps"? wouldn't be better if go from http straight to https like this?

http://www.site.com/forums/showthread.php?t=212121 > https://www.site.com/threads/212121/

I would really appreciate any input.
 
You last "doesn't work" example works for me on your site. I suspect you're seeing a cached result.

As for redirecting to HTTPS directly, you should be able to change your redirect "targets" to a full URL, including the HTTPS protocol. Provided these redirects are processed before your general http->https redirects, it should do the redirection in fewer steps.
 
Thanks Mike, I cleared the cache and now the redirects are working, however I still have a lot of backlinks missing due to 404 errors..

these urls:
http://www.site.com/forums/mainforum-194/testing-thread-11041
http://www.site.com/forum194/thread11041.html

should redirect to this url:
http://www.site.com/threads/testing-thread.11041/

I tried several rewrite rules without success, would you help me ? I really need it man..

Also how can I change the redirect "targets" to a full URL? At this point I'm not really sure what to do.
 
Untested, but you can try these:
Code:
RerwriteRule ^forums/[^/]+-\d+/[^/]+-(\d+)$ https://example.com/threads/$1/ [R=301,L]
RewriteRule thread(\d+)\.html$ https://example.com/threads/$1/ [R=301,L]
Those are also examples of what I meant by making the redirect target be a full URL.
 
Untested, but you can try these:
Code:
RerwriteRule ^forums/[^/]+-\d+/[^/]+-(\d+)$ https://example.com/threads/$1/ [R=301,L]
RewriteRule thread(\d+)\.html$ https://example.com/threads/$1/ [R=301,L]
Those are also examples of what I meant by making the redirect target be a full URL.

Thank you Mike!!

this worked for the urls with the word "thread" at the end :

Code:
RewriteRule thread(\d+)\.html$ https://example.com/threads/$1/ [R=301,L]

but unfortunately the other one
Code:
RerwriteRule ^forums/[^/]+-\d+/[^/]+-(\d+)$ https://example.com/threads/$1/ [R=301,L]

didn't work, and I still see that I have a ton of urls like this:

http://www.site.com/example-forum/18031-this-is-an-example.html
http://www.site.com/another-forum/19178-anewthread-t5-t8-post215382.html

The good thing is that the IDs are preserved...
 
You appear to have a lot of different URL formats. Did you change them regularly? For the additional URLs, you could try:
Code:
RewriteRule /(\d+)-[^/]+\.html$ https://example.com/threads/$1/ [R=301,L]

For the one that didn't work, we can go a bit more generic:
Code:
RewriteRule \d+/[^/]+-(\d+)$ https://example.com/threads/$1/ [R=301,L]
This does run the risk of being hit unexpectedly at times, so keep an eye out for that. Hopefully shouldn't happen with XF's URL structure though.
 
Last edited:
Top Bottom