Forum Moderators: phranque
#RewriteEngine on
#RewriteCond %{HTTP_HOST} ^mysite.co.uk$ [OR]
#RewriteCond %{HTTP_HOST} ^mysite.co.uk$
#RewriteRule ^(.*)$ public_html/mysite/$1 [R=301,L]#RewriteCond %{HTTP_REFERER} ^examplesite.com*
#RewriteRule ^/$ redirectsite.com [R]
The last two lines are the part I'm unsure about. The first part was already in my htaccess file, I don't know if it's affecting the latter in any way. I know nothing about htaccess and the like. If someone could spell out what I'm doing wrong I'd really appreciate the help.
Thank you in advance.
RewriteCond %{HTTP_REFERER} ^http://(www\.)?example\.com
RewriteRule .* http://redirectsite.com/ [R=302,L]
I'd also suggest reversing the rules -- There's no use doing a domain canonicalization redirect if you're going to pass the request to another site anyway.
I assume that you want to redirect *all* URL requests referred from example.com to redirectsite.com, so I have changed the RewriteRule pattern accordingly.
Unless you actually need to deliver desirable traffic to redirectsite, consider, that it is bad practice to pass off problems to another site. If you simply want to dump the traffic from example.com, change the RewriteRule to:
RewriteRule .* - [F]
I also assume that in your actual code, the domains given in your first two RewriteConds are not really identical. If so, you can delete the first (redundant) RewriteCond.
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim