LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > LiteSpeed Web Server > General > [Resolved] RewriteRule help

Reply
 
Thread Tools Display Modes
  #1  
Old 04-06-2010, 12:23 PM
diggs diggs is offline
New Member
 
Join Date: Jan 2009
Posts: 6
Default [Resolved] RewriteRule help

Hi there!

I did some extensive searching on the forums here and was unable to find what I'm looking for. I'm hoping someone can point me in the right direction here. What I'm trying to accomplish I thought was pretty simple however it's proving to be a bit tougher than originally thought.

What I'm trying to do is simply replace certain characters in the QUERY_STRING with a RewriteRule and then redirect to this filtered url.

The behavior of this code does what I want it to do, however it does not include the QUERY_STRING which is what I need.
Code:
RewriteRule ^(.*)-(.*)$ /$1_$2 [N]
Currently this rewrite rule will change:
  • this-file-test.php -> this_file_test.php

What I need to do is:
  • this-file-test.php?t=this-is-a-test -> this-file-test.php?t=this_is_a_test

I believe what I need to do is something like....
Code:
RewriteCond %{QUERY_STRING} ^/(.*)-(.*)$ 
RewriteRule ^(.*)$ /%1_%2 [N]
...however the proper syntax to accomplish this is escaping me. (is it even possible?)

My only option here is to use lsws rewrite or a .htaccess file. As much as I'd love to just do this in code which would be SO much easier, the code is written by a 3rd party developer and I do not have the ability to alter it due to our contract with them.

Does anyone have any suggestions?

Thanks in advance for any help on this.

Last edited by NiteWave; 04-07-2010 at 06:28 PM..
Reply With Quote
  #2  
Old 04-06-2010, 08:23 PM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,227
following one works on my test machine:
Code:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^(.*)-(.*)$  
RewriteRule ^(.*)$ $1?%1_%2 [N]
Reply With Quote
  #3  
Old 04-07-2010, 06:18 PM
diggs diggs is offline
New Member
 
Join Date: Jan 2009
Posts: 6
Perfect! Thank you kindly
__________________
~ diggs
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:07 PM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.