This forum has been moved here:
Helicon Tech Community Forum

Helicon Ape (Forum Locked Forum Locked)
 Helicon Tech : Helicon Ape
Subject Topic: escaping characters not workin
Author
Message |
ianwood
Newbie


Joined: 10 November 2010
Posts: 2
Posted: 10 November 2010 at 4:28am

Hi guys n gals!

First post in here so please be nice ;)

I have the following rewrite rules:

RewriteRule ^([a-zA-Z0-9]*)/([a-zA-Z0-9]*)\.php\?(.*)
/$2.php?shop=$1&$3 [NC,L]
RewriteRule ^([a-zA-Z0-9]*)/([a-zA-Z0-9]*)\.php /$2.php?
shop=$1 [NC,L]

#foxhub rules to find shop out
RewriteRule ^([a-zA-Z0-9]*)/$ /index.php?shop=$1 [L,NC]
RewriteRule ^([a-zA-Z0-9]*)$ /index.php?shop=$1 [L,NC]

the result of which SHOUL redirect the following:

www.site.com/Sells
    -> /index.php?shop=Sells [works]

www.site.com/Sells/menu.php?Cat=1
    -> /menu.php?shop=Sells&Cat=1 [failing]
    -> /menu.php?shop=Sells [which is 'wrong']

the last example SHOULD get matched by rewrite [1]...

I have tested the rules with the regex tester shipped
with ape and found that escaping ? and . don't seem to
work.

I am a little flumoxed and would appreciate anyone who
could shed some light on why this escaping is not
working.

Loads of thanks in advance.
Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 11 November 2010 at 8:17am

Hello,

The main idea with the rules with query string is that you place query string in a separate condition
instead:
Quote:
RewriteRule ^([a-zA-Z0-9]*)/([a-zA-Z0-9]*)\.php\?(.*) /$2.php?shop=$1&$3 [NC,L]

as following:
Code:
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^([a-zA-Z0-9]*)/([a-zA-Z0-9]*)\.php$ /$2.php?shop=$1&%1? [NC,L]

but more correct way would be:
Code:
RewriteRule ^([a-zA-Z0-9]*)/([a-zA-Z0-9]*)\.php$ /$2.php?shop=$1 [QSA,NC,L]


[QSA] - automatically appends query string

Regards
Andrew
Back to Top
 
ianwood
Newbie


Joined: 10 November 2010
Posts: 2
Posted: 11 November 2010 at 8:44am

D'Oh - that's an ENORMOUS omission on my part - I do
apologize...

I shall never darken your door again. ;)

spent so long concentrating on the regex didn't even glance
at the flags...

Thanks

Back to Top
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version