Appending a single 0 (zero) to end of URLs, when facebook.com is the referrer
I need to append a 0 (zero) to the end of each of my URLs when visitors click in from facebook.com.
I was able to get this working by using this in my .htaccess:
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(www\.)?facebook\.com [NC]
RewriteCond %{QUERY_STRING} ^$
RewriteRule . %{REQUEST_URI}?id=FB [R=301,L]
The problem is, I don't want to use a question mark, and when trying this below code in my .htaccess, the URL is destroyed (I get several zeros instead of just the one).
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(www\.)?facebook\.com [NC]
RewriteCond %{QUERY_STRING} ^$
RewriteRule . %{REQUEST_URI}0 [R=301,L]
Is it posible to append just the single zero to the end of my URLs using开发者_StackOverflow this method? Thanks for any guidance.
Sure you can -- but it greatly depends on URLs you are using.
You need to add 1 extra condition and only redirect if requested URL does not contain 0
at the end already (this will be the "redirect mark" -- evidence that URL has already been redirected). This is the only known to me way under such circumstances/requirements.
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(www\.)?facebook\.com [NC]
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{REQUEST_URI} !0$
RewriteRule . %{REQUEST_URI}0 [R=301,L]
Obviously (as I have mentioned on very beginning) -- this will not work if URL already ends with 0
(we are talking about path part of URL, not query string).
精彩评论