Query string stripped and ignoring rewritecond

Topics: Developer Forum, User Forum
Oct 14, 2012 at 5:13 PM
Edited Oct 16, 2012 at 9:19 AM

Hi there,

I am quite new to iirf that we have running to present clean urls to our site. 

OK - Looking through the documentation - I have managed to strip the url using:

RewriteRule ^/(https?)://([^/]+)(/([^\?]+(\?(.*))?)?)?  /$1
RewriteRule ^/(.+)\?(.+)$       http://betatest.bracknell-forest.gov.uk/$1 [R=301]

then I have:

# Any bare URL will get rewritten to a URL with .htm appended
RewriteRule ^/([\w]+)$ /$1.htm [I,L]
RedirectRule ^/(.+)\.(htm)$       http://betatest.bracknell-forest.gov.uk/$1 [R=301]

The problem is we have some pages where we need the following to be requested:

http://betatest.bracknell-forest.gov.uk/news.asp?page=2

This now resolves to

http://betatest.bracknell-forest.gov.uk/news

the following strips the asp:

 

# Redirect to ASP if it exists.
# e.g. example.com/foo will display the contents of example.com/foo.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.asp -f
RewriteRule ^(.+)$ $1.asp [L,QSA]
RedirectRule ^/(.+)\.(asp)$       http://betatest.bracknell-forest.gov.uk/$1 [R=301]

 

but http://betatest.bracknell-forest.gov.uk/news.asp?page=2 does not return page 2.

Oct 15, 2012 at 6:11 PM
Edited Oct 16, 2012 at 9:18 AM

Forgot to mention - we also have a rewrite condition that does not seem to work to try to restrict stripping the query string if it contains fb_action_ids=

RewriteCond %{QUERY_STRING} ^ fb_action_ids=(.)$ [I]

Oct 17, 2012 at 4:37 PM
Edited Oct 17, 2012 at 4:39 PM

Doesn't look like this discussion board is being contributed to/maintained anymore?  I managed to fix my problem.  For anyone interested here is the fixed code:

#key thing I have changed is to specify the query string parameters fb_action_ids and fb_source 
RewriteRule ^/(https?)://([^/]+)(/([^\?]+(\?(.*))?)?)? /$1
RewriteRule ^/(.+)\?(fb_action_ids=(.*)|fb_source=(.*))$ http://betatest.bracknell-forest.gov.uk/$1 [R=301]

# e.g. example.com/foo will display the contents of example.com/foo.asp
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.asp -f
RewriteRule ^(.+)$ $1.asp [L,QSA]
RedirectRule ^/(.+)\.(asp)$ http://betatest.bracknell-forest.gov.uk/$1 [R=301]

# Any bare URL will get rewritten to a URL with .htm appended
RewriteRule ^/([\w]+)$ /$1.htm [I,L]
RedirectRule ^/(.+)\.(htm)$ http://betatest.bracknell-forest.gov.uk/$1 [R=301]