Sciencemadness Discussion Board
Not logged in [Login ]
Go To Bottom

Printable Version  
Author: Subject: Forum Tweak (Transmogrify Links)
R0b0t1
Harmless
*




Posts: 26
Registered: 2-1-2010
Location: Sniping
Member Is Offline

Mood: No Mood

[*] posted on 4-1-2010 at 19:10
Forum Tweak (Transmogrify Links)


Hello, posting to ask if it would be possible to change /talk/ to /whisper/ or vis versa automagically if connecting via the respective URL. I'm sure it could be done, but not sure how much would need to be changed/written. Thanks if it could happen, though. Won't be killed if it can't ;)

Ta, R0b0t1.
View user's profile View All Posts By User
Polverone
Now celebrating 21 years of madness
*********




Posts: 3186
Registered: 19-5-2002
Location: The Sunny Pacific Northwest
Member Is Offline

Mood: Waiting for spring

[*] posted on 4-1-2010 at 19:19


Do you mean that if you accidentally type in

http://www.sciencemadness.org/whisper/post.php?action=reply&...

that you want to be transparently redirected to

http://www.sciencemadness.org/talk/post.php?action=reply&...

and vice versa?




PGP Key and corresponding e-mail address
View user's profile Visit user's homepage View All Posts By User
R0b0t1
Harmless
*




Posts: 26
Registered: 2-1-2010
Location: Sniping
Member Is Offline

Mood: No Mood

[*] posted on 4-1-2010 at 19:22


No, sorry I wasn't very clear, exactly. I wanted it to translate links embedded in posts to the respective forum you're currently viewing. Ex: I click on a link that's /talk/, it brings me to /whisper/, if I am viewing from /whisper/.

EDIT: Actually, that might be what you mean. I just couldn't tell.

[Edited on 5-1-2010 by R0b0t1]
View user's profile View All Posts By User
Polverone
Now celebrating 21 years of madness
*********




Posts: 3186
Registered: 19-5-2002
Location: The Sunny Pacific Northwest
Member Is Offline

Mood: Waiting for spring

[*] posted on 4-1-2010 at 19:42


I think that should be possible with the Apache rewrite module, by checking the referrer and rewriting the link if the destination appears to be a forum URL, the referrer appears to be a forum URL, and there is a mismatch between the two (talk going to whisper or whisper going to talk).

If there's anyone more familiar with the rewrite module than I am who wants to take a crack at the problem, I'll try rules you can come up with. Otherwise a fix may be slow in coming, because rewrite rules make my eyes glaze over and I have so far avoided learning to use the module.




PGP Key and corresponding e-mail address
View user's profile Visit user's homepage View All Posts By User
R0b0t1
Harmless
*




Posts: 26
Registered: 2-1-2010
Location: Sniping
Member Is Offline

Mood: No Mood

[*] posted on 4-1-2010 at 20:01


Hm, I was thinking you'd do it with the forum software (I would think it would be easier than an Apache module), but if that's the way that stands out to you, I might look it up, later...

Besides saying "omgz apache sux", I'll be on my way. Maybe someone else can get something working? ;)
View user's profile View All Posts By User
watson.fawkes
International Hazard
*****




Posts: 2793
Registered: 16-8-2008
Member Is Offline

Mood: No Mood

[*] posted on 4-1-2010 at 21:43


Quote: Originally posted by Polverone  
I think that should be possible with the Apache rewrite module, by checking the referrer and rewriting the link if the destination appears to be a forum URL, the referrer appears to be a forum URL, and there is a mismatch between the two (talk going to whisper or whisper going to talk).
That should work, but I'm completely with you about the eyes-glazing-over problem with rewrite rules.
View user's profile View All Posts By User
turd
National Hazard
****




Posts: 800
Registered: 5-3-2006
Member Is Offline

Mood: No Mood

[*] posted on 5-1-2010 at 07:53


You mean something as blunt as:

RewriteEngine On

RewriteCond %{HTTP_REFERER} https://(www\.)?sciencemadness\.org/.*
RewriteRule /talk/(.*) https://hostname.goes.here/whisper/$1 [R,L]

RewriteCond %{HTTP_REFERER} http://(www\.)?sciencemadness\.org/.*
RewriteRule /whisper/(.*) http://hostname.goes.here/talk/$1 [R,L]

??

(Untested since I have no webserver - will need some tweaking)

Wouldn't solve the problem that when using https:// for "security" by the time you are getting the redirect the URL has been sent plaintext.

BTW: For some weird reason the board sets the "security-flag" only for two out of five cookies. (The password and the username cookie).

Edit: need '\' before '.' of course..
Edit: and '?' instead of '+', sheesh...

[Edited on 5-1-2010 by turd]

[Edited on 5-1-2010 by turd]

[Edited on 5-1-2010 by turd]
View user's profile View All Posts By User
Polverone
Now celebrating 21 years of madness
*********




Posts: 3186
Registered: 19-5-2002
Location: The Sunny Pacific Northwest
Member Is Offline

Mood: Waiting for spring

[*] posted on 5-1-2010 at 10:36


The forum software cannot handle this. If anything, it will be Apache that handles this. Thanks for that starting point for rewrite rules, turd.

A few years ago you could access https://www.sciencemadness.org/talk/ or http://www.sciencemadness.org/talk/ with equal ease. That stopped one or two XMB software upgrades ago. The problem is that part of XMB's configuration requires an absolute path to the forum root, and a path starting with https is different from one starting with https. I asked the XMB developers why my old setup worked with the older forum software and they said it was a mistake that it had ever worked with https and http both going to talk. So I configured an almost-identical copy of the XMB software for the https site, with the only difference that the directory used is 'whisper' instead of 'talk' with the configuration file changed accordingly.




PGP Key and corresponding e-mail address
View user's profile Visit user's homepage View All Posts By User
Polverone
Now celebrating 21 years of madness
*********




Posts: 3186
Registered: 19-5-2002
Location: The Sunny Pacific Northwest
Member Is Offline

Mood: Waiting for spring

[*] posted on 5-1-2010 at 22:40
no success so far


I started out with a single rule, for the whisper-origin version of the problem. I enabled the rewrite module and added these directives to the top-level .htaccess in /var/www/:

RewriteCond %{HTTP_REFERER} https://(www\.)?sciencemadness\.org/.*
RewriteRule http://www.sciencemadness.org/talk/(.*) https://www.sciencemadness.org/whisper/$1 [R,L]

It does not seem to do anything. I always browse the https site, but clicking on links that go to /talk/ still sends me to /talk/. I tested a very simple rewrite rule and it worked, so I think the module is running. I just have not given it the proper incantation to fix up the forum URLs.




PGP Key and corresponding e-mail address
View user's profile Visit user's homepage View All Posts By User
turd
National Hazard
****




Posts: 800
Registered: 5-3-2006
Member Is Offline

Mood: No Mood

[*] posted on 6-1-2010 at 13:21


Ho hum... I had a look at the "wonderful" documentation.
This:
--- RewriteRule http://www.sciencemadness.org/talk/(.*) https://www.sciencemadness.org/whisper/$1 [R,L]
is definitely wrong. At this point there is no hostname anymore. It should read somehow like this:
--- RewriteRule ^/talk/(.*) https://www.sciencemadness.org/whisper/$1 [R,L]
The caret means only match at the start - you probably don't want to rewrite any URL with a "/talk/" inside.

As to the RewriteCond line, in principle it looks correct, unless I'm missing something that is. It could be optimized by a caret and a [NC], meaning case insensitive:
--- RewriteCond %{HTTP_REFERER} ^https://(www\.)?sciencemadness\.org/.* [NC]

In any case, maybe try it without the RewriteCond. Then it should rewrite the /talk/ links every time, but at least it will be clear which one (if not both) of the two lines is problematic.
View user's profile View All Posts By User
Polverone
Now celebrating 21 years of madness
*********




Posts: 3186
Registered: 19-5-2002
Location: The Sunny Pacific Northwest
Member Is Offline

Mood: Waiting for spring

[*] posted on 6-1-2010 at 16:12


Thanks for your continuing help. I first commented out the RewriteCond. Links are still not rewritten. Then I replaced the existing RewriteRule with:

RewriteRule ^/talk/(.*) https://www.sciencemadness.org/whisper/$1 [R,L]

When I clicked on /talk/ links they were still not rewritten. I thought the rules themselves would not be too different from RedirectMatch commands, which I am using without trouble, but so far I have no luck.




PGP Key and corresponding e-mail address
View user's profile Visit user's homepage View All Posts By User
turd
National Hazard
****




Posts: 800
Registered: 5-3-2006
Member Is Offline

Mood: No Mood

[*] posted on 8-1-2010 at 02:27


Sorry, then I don't know what the problem is. :( It does looks ok. Maybe it clashes with other RewriteRules or is transformed before it reaches the RewriteRules?

The only last idea I have is to turn on RewriteRule debugging:

RewriteLog "/path/to/some/writeable/directory/rewrite_debug.log"
RewriteLogLevel 3
View user's profile View All Posts By User

  Go To Top