3

On my website I have URLs like this:

http:// www.domain.com/something-like-page-title-4en

With ISAPI Rewriter (Ionics Isapi Rewrite Filter) I have following rule:

RewriteRule ^/([^.?]+[^.?/])$  /index.php?URL_string=$1 [L,U]

That means, above rule is transforming above URL to:

http://www.domain.com/index.php?URL_string=something-like-page-title-4en

If someone likes above URL on Facebook, Facebook adds additional tracking parameters into my URL and it looks like:

http://www.domain.com/something-like-page-title-4en?fb_action_ids=2159471566173547&fb_action_types=og.likes&fb_source=712&action_object_map=%7B%2780201701278628651%22%3A10110880521592526%7D&action_type_map=%7B%2210201714908651773%22%3A%22og.likes%22%7D&action_ref_map=%5B%5D

My above rule is not able to process such URL (with a query string). What I need is rule which will be able to catch both URLs, with query strings and without them, and to process URLs as follows:

Example 1 (URL with Query String):

Original URL:

http://www.domain.com/something-like-page-title-4en?param1=value1&param2=value2

Rewritten URL:

http://www.domain.com/index.php?URL_string=something-like-page-title-4en&param1=value1&param2=value2

Example 2 (URL without Query String):

Original URL:

http://www.domain.com/something-like-page-title-4en

Rewritten URL:

http://www.domain.com/index.php?URL_string=something-like-page-title-4en

Thanks a lot.

Misko
  • 43
  • 7

1 Answers1

2

Use QSA (Query String Append) flag:

RewriteRule ^/?([^/]+)/?$ /index.php?URL_string=$1 [L,U,QSA]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • It helped just a little bit. With my old rule I had "404 - Page not found" error. With your rule ISAPI rewriter catches the request, but not as wanted. If I have http://www.domain.com/something-like-page-title-4en?param1=value1&param2=value2 as original URL, I want it to be rewritten as http://www.domain.com/index.php?URL_string=something-like-page-title-4en&param1=value1&param2=value2 .... with your rule I'm getting it as http://www.domain.com/index.php?URL_string=something-like-page-title-4sr?param1=value1&param2=value2 ... As you can see, there are 2 question marks. – Misko Aug 26 '13 at 21:46
  • Ok edited, try it now. Its pretty late here so if it doesn't work, pls leave a comment and I will attend when I wake up in morning. – anubhava Aug 26 '13 at 21:57
  • Unfortunatelly, I can't see any change in result. Although you changed the rule, result is still same. – Misko Aug 26 '13 at 22:10
  • Sorry then I won't be of much help since both these changes worked for me. There must be some ISAPI tricks involved. – anubhava Aug 26 '13 at 22:11
  • I appreciate your efforts. I believe we are near to the solution. I'm getting URL_string=something-like-page-title-4sr?param1=value1 ... if you can replace this question mark ...-4sr(?)param1=... with ampersand (&), I think it could be wanted solution. Thanks. – Misko Aug 26 '13 at 22:28
  • It's still not working as wanted. I'm still getting URL_string=something-like-page-title-4sr?param1=value1 instead of just part before question mark (URL_string=something-like-page-title-4sr) ..... but, I can use your rule to achieve this point and after that I can use PHP to shorten URL_string parametar and to take just this first part (before quetion mark). Although we have not found right solution I'm very thankful for your efforts and your time. Thanks. ... I want to give you a +1, but I don't have enough points (reputation) :( – Misko Aug 27 '13 at 21:51
  • You're welcome and sorry that solution is not 100% correct. I have no way to test ISAPI at my end so all my testing was done in Apache mod_rewrite and it worked for me. – anubhava Aug 28 '13 at 06:16