Passing & appending querystrings

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 4
Joined: 17 Jul 2013, 05:55

Passing & appending querystrings

17 Jul 2013, 06:04

Hi,

I'm trying to set up a Redirect Rule that forwards to a current search results page with a new QueryString appended to allow the page to know to operate the search in a different way.

So forward searchtwo.asp?query=blah to search-result.asp?searchtype=tag&query=blah


I had thought this would be :

RewriteRule ^searchtwo\.asp search-result.asp?searchtype=tag [QSA]

I can't get it to pass the appended tag querystring (searchtype), although if I add the additional querystring to the original page (searchtwo.asp) then this does load the redirect page fine.


This would be a better way of doing it, but again I've had no luck managing to get it to work:

/searchtwo/blah to search-result.asp?searchtype=tag&query=blah


Any help you could give would be appreciated.

Thanks,

Rick

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: Passing & appending querystrings

17 Jul 2013, 07:41

Hello, Rick

"This would be a better way of doing it, but again I've had no luck managing to get it to work:
/searchtwo/blah to search-result.asp?searchtype=tag&query=blah"

Please try the following rule for that:

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^searchtwo/(.+)$ /search-result.asp?searchtype=tag&query=$1 [NC,L]

If it doesn't work, please enable logging in httpd.conf by putting

RewriteLogLevel 9

And provide rewrite.log records for the test request.

User avatar
Posts: 4
Joined: 17 Jul 2013, 05:55

Re: Passing & appending querystrings

17 Jul 2013, 08:45

Hi Anton,

That still isn't working correctly, log files are below.

On the last line I think it's trying to apply that pattern to another file as well ?

Thanks,

Rick

192.168.1.198 192.168.1.198 Wed, 17-Jul-2013 12:18:07 GMT [XXXXXX.com/sid#1895803666][rid#20193808/initial] (2) init rewrite engine with requested uri /searchtwo/rose
192.168.1.198 192.168.1.198 Wed, 17-Jul-2013 12:18:07 GMT [XXXXXX.com/sid#1895803666][rid#20193808/initial] (1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
192.168.1.198 192.168.1.198 Wed, 17-Jul-2013 12:18:07 GMT [XXXXXX.com/sid#1895803666][rid#20193808/initial] (1) Htaccess process request c:\inetpub\wwwroot\XXXXXX.com\.htaccess
192.168.1.198 192.168.1.198 Wed, 17-Jul-2013 12:18:07 GMT [XXXXXX.com/sid#1895803666][rid#20193808/initial] (3) applying pattern '^searchtwo/(.+)$' to uri 'searchtwo/rose'
192.168.1.198 192.168.1.198 Wed, 17-Jul-2013 12:18:07 GMT [XXXXXX.com/sid#1895803666][rid#20193808/initial] (4) RewriteCond: input='C:\Inetpub\wwwroot\XXXXXX.com\searchtwo\rose' pattern='!!-f' => matched
192.168.1.198 192.168.1.198 Wed, 17-Jul-2013 12:18:07 GMT [XXXXXX.com/sid#1895803666][rid#20193808/initial] (4) RewriteCond: input='C:\Inetpub\wwwroot\XXXXXX.com\searchtwo\rose' pattern='!!-d' => matched
192.168.1.198 192.168.1.198 Wed, 17-Jul-2013 12:18:07 GMT [XXXXXX.com/sid#1895803666][rid#20193808/initial] (1) Rewrite URL to >> /search-result.asp?search=rose&tag=yes
192.168.1.198 192.168.1.198 Wed, 17-Jul-2013 12:18:07 GMT [XXXXXX.com/sid#1895803666][rid#20193808/initial] (2) rewrite 'searchtwo/rose' -> '/search-result.asp?search=rose&tag=yes'
192.168.1.198 192.168.1.198 Wed, 17-Jul-2013 12:18:07 GMT [XXXXXX.com/sid#1895803666][rid#20193808/initial] (2) internal redirect with /search-result.asp?search=rose&tag=yes [INTERNAL REDIRECT]

192.168.1.198 192.168.1.198 Wed, 17-Jul-2013 12:18:07 GMT [XXXXXX.com/sid#1895803666][rid#20199728/initial] (2) init rewrite engine with requested uri /search-xml.asp?tag_query=&search_query=&productsize=&price_low=&price_high=
192.168.1.198 192.168.1.198 Wed, 17-Jul-2013 12:18:07 GMT [XXXXXX.com/sid#1895803666][rid#20199728/initial] (1) Htaccess process request C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
192.168.1.198 192.168.1.198 Wed, 17-Jul-2013 12:18:07 GMT [XXXXXX.com/sid#1895803666][rid#20199728/initial] (1) Htaccess process request c:\inetpub\wwwroot\XXXXXX.com\.htaccess
192.168.1.198 192.168.1.198 Wed, 17-Jul-2013 12:18:07 GMT [XXXXXX.com/sid#1895803666][rid#20199728/initial] (3) applying pattern '^searchtwo/(.+)$' to uri 'search-xml.asp'

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: Passing & appending querystrings

18 Jul 2013, 07:34

So, it rewrites

/searchtwo/rose
to
/search-result.asp?search=rose&tag=yes

Is that the desired result? If not, what it should be?

User avatar
Posts: 4
Joined: 17 Jul 2013, 05:55

Re: Passing & appending querystrings

18 Jul 2013, 08:18

Hi Anton,

I agree that it appears to be passing the querystring correctly, however the page (search-result.asp) does not show the same content for:

searchtwo/rose as it does for search-result.asp?search=rose&tag=yes

there are no search results on searchtwo/rose

and 2 search results with search-result.asp?search=rose&tag=yes

This may be because of some of the AJAX running the search ? Am I right in thinking it really shouldn't make any difference to ISAPI Rewrite ?

Thanks,

Rick

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: Passing & appending querystrings

18 Jul 2013, 11:05

Hello, Rick

It's actually not quite clear why you want to make search queries SEO friendly. Usually it's senseless.
Can you clarify?

User avatar
Posts: 4
Joined: 17 Jul 2013, 05:55

Re: Passing & appending querystrings

18 Jul 2013, 11:48

Hi Anton,

These are tags/categories rather than just a search page so it would be useeful to have them displayed in a user friendly way muchlike Wordpress does.

Thanks,

Rick

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: Passing & appending querystrings

22 Jul 2013, 05:59

Hello, Rick

Ok, I see...
AJAX is definitely not a problem.
Please make sure you don't have ISAPI_Rewrite registered twice - on server and site level, if you are on IIS6.
And also tell if any other rules are working fine for you.

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 13 guests