Forum Moderators: phranque
I'm having a problem with a rewrite I want to do. Basically, I want to redirect traffic from a certain site to a specific page on my site. I don't see how this would be any different than redirecting to a customized homepage according to the user agent (except for using a different type of RewriteCond), but it doesn't work.
This is the code:
RewriteEngine on
#Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_REFERER} ^http://www.originating-site\.com [NC]
RewriteRule ^.*$ /target-page-on-my-site.html [R]
what happens when it "doesn't work"?
what response do you get in the browser?
what do you see in the error log?
i notice you didn't escape the first "." in the RewriteCond but that shouldn't cause much problem in this case...
It doesn't get redirected to the inner page i wanted. Instead of going to www.mydomain.com/target-page-on-my-site.html, it goes to www.mydomain.com. This is where the link is pointing to on the referring site, I just want to send the visitors coming through that link to a different page.
what response do you get in the browser?
As I described above, I don't get an error code, not a 404 nor a 500. I get the homepage...
what do you see in the error log?
I don't have an error log, but my access log shows this:
[My IP] - - [24/Nov/2007:05:03:16 -0500] "GET /target-page-on-my-site.html HTTP/1.1" 302 223 "http://www.linking-domain.com/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9" 10330
[My IP] - - [24/Nov/2007:05:03:16 -0500] "GET /target-page-on-my-site.html HTTP/1.1" 302 223 "http://www.linking-domain.com/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9" 10330
What happens if you use the 'full' form of the redirect?RewriteCond %{HTTP_REFERER} ^http://www\.originating-site\.com [NC]
RewriteCond %{REQUEST_URI}!^/target-page-on-my-site\.html
RewriteRule .* http://www.example.com/target-page-on-my-site.html [R=301,L]Jim
Hi Jim,
This seems to have done the trick.
Thank you very much!
So the problem was not using the full URL in the RewriteRule or not using the RewriteCond of %{REQUEST_URI}?