Forum Moderators: phranque
if url-1 !mydomain
redirect url-1 to [mysite.com...]
I've tried this, but the RewriteConds don't work
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^http://www\.mysite\.com [NC]
RewriteRule ^(.*) [mysite.eu...] [R=301,L]
The result I want is: [mysite.eu...]
Any idea?
Also, there is no apparent need to do an external redirect: An internal rewrite to the script should suffice, and then the script can do its external redirect.
RewriteCond %{HTTP_HOST} !^(www\.)?example\.eu [NC]
RewriteCond %{HTTP_HOST} ^([^:]+)(:[0-9]+)?$
RewriteRule (.*) /redirect/index.php?option=http://%1/$1 [L]
The second subpattern in the second RewriteRule allows (but does not require) a port number appended to the hostname.
Jim
RewriteCond %{HTTP_HOST}!^(www\.)?example\.eu [NC]
RewriteCond %{HTTP_HOST} ^([^:]+)(:[0-9]+)?$
RewriteRule (.*) /redirect/index.php?option=http://%1/$1 [L]
It has no effect. If I click an external link the browser open that URL immediately. And I did several other attempts.
Perhaps I cannot obtain that I would using htaccess :(
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^(www\.)?mysite\.eu [NC]
RewriteCond %{HTTP_HOST} ^([^:]+)(:[0-9]+)?$
RewriteRule (.*) /redirect/index.php?option=http://%1/$1 [L]
This .html file is in the root:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<a href="http://www.google.com">link</a>
</body>
</html>
When I click on the link, the browser opens the Google homepage.
The code seems to be correct and in the past I've already used the rewriterules on the same server...
?
Mario
I assume you're trying to do exit-click-tracking, and if so, you will have to change the link on your page to point to your own server, like <a href="http://www.example.com/exit-tracker/http://www.google.com">Go to Google</a> and then write a rule to handle that.
Alternately, you can use client-side JavaScript to load a 1x1 transparent image from your server whenever an outbound link on your page is clicked, and track the outgoing click based on that. Google uses this exact method [webmasterworld.com] periodically to track clicks on the top three or four search results listings.
Jim