mod rewrite to remove facebook query string

Posted by user905752 on Stack Overflow See other posts from Stack Overflow or by user905752
Published on 2012-10-04T14:15:21Z Indexed on 2012/10/09 3:37 UTC
Read the original article Hit count: 221

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.

© Stack Overflow or respective owner

Related posts about facebook

Related posts about mod-rewrite