mod rewrite to remove facebook query string
- by user905752
I can't get my query string to work..please help...
I have the following url:
http://betatest.bracknell-forest.gov.uk/help?fb_action_ids=372043216205703&fb_action_types=og.likes&fb_source=aggregation&fb_aggregation_id=288381481237582
(sorry but the page will be unavailable as it is a test internal domain link)
I want the following url:
http://betatest.bracknell-forest.gov.uk/help
I get a browser message saying 'The system cannot find the file specified.'
I know it is because I already have a mod rewrite to remove the .htm from the page name to return clean urls but I don't know what I need to do to accept a clean url and return the page.
Here is the mod rewrite code I have:
RewriteRule ^/([\w]+)$ /$1.htm [I,L] #Any bare URL will get rewritten to a URL with .htm appended
RedirectRule ^/(.+)\.(htm)$ http://betatest.bracknell-forest.gov.uk/$1 [R=301]
RewriteCond %{QUERY_STRING} ^fb_action_ids=(.)$ #if the query string contains fb_action_ids
RewriteCond %{QUERY_STRING} !="" #if there is a query string
RewriteRule ^(.*) $1? [R=301,L]
I think it is because I am using R=301 twice but do not know what I need to use as an alternative.
If I append .htm from help?fb_action_ids.... to help.htm?fb_action_ids.... this returns the required page fine but I need to return the page name for the non appended url.
Many thanks for any help in advance.