How to Create website Referel Address ?
SEO Help and Tips
How to Create website Referel Address ?
Website .htaccess rules that redirect specific referral addresses to different destinations and also in Google search Consol:
Java Code:
<script type='text/javascript'>
// Define the referrer and destination mappings
const referrerDestinationMap = {
'source29.medium.com': 'https://example.com',
'linkedin.com': 'https://example.com',
'facebook.com': 'https://example.com',
'twitter.com': 'https://example.com',
'tumblr.com': 'https://example.com',
'pinterest.com': 'https://example.com',
};
// Get the referring domain from the current URL
const referringDomain = document.referrer.split('/')[2];
// Check if the referring domain is in the mapping
if (referrerDestinationMap.hasOwnProperty(referringDomain)) {
// Redirect to the corresponding destination URL
window.location.href = referrerDestinationMap[referringDomain];
}
</script>
In the <script> tag of an HTML page: You can place the JavaScript code within a <script> tag in the <head> section or just before the closing </body> tag of your HTML page. This will allow the code to execute when the page loads.
In an external JavaScript file: If you have multiple pages or want to keep your JavaScript code separate from your HTML, you can create an external JavaScript file (e.g., redirect.js) and include it using a <script> tag in your HTML file. Make sure to link the JavaScript file correctly using the src attribute of the <script> tag.
As a part of a specific JavaScript function: If you want to trigger the redirection based on certain events or conditions, you can encapsulate the JavaScript code within a function. Then, you can call that function whenever the desired condition is met.
On Google Blogger, you have limited control over the available settings and customization options. If you want to redirect specific referral addresses on your Google Blogger blog, you would need to explore alternative methods provided by the platform itself.
Google Blog Code:
<?xml version="1.0" encoding="UTF-8"?>
<rules>
<rule>
<referrer>https?://medium\.com/</referrer>
<destination>https://www.example.com/destination1</destination>
</rule>
<rule>
<referrer>https?://(www\.)?linkedin\.com/</referrer>
<destination>https://www.example.com/destination2</destination>
</rule>
<rule>
<referrer>https?://(www\.)?facebook\.com/</referrer>
<destination>https://www.example.com/destination3</destination>
</rule>
<rule>
<referrer>https?://(www\.)?twitter\.com/</referrer>
<destination>https://www.example.com/destination4</destination>
</rule>
<rule>
<referrer>https?://(www\.)?tumblr\.com/</referrer>
<destination>https://www.example.com/destination5</destination>
</rule>
<rule>
<referrer>https?://(www\.)?pinterest\.com/</referrer>
<destination>https://www.example.com/destination6</destination>
</rule>
</rules>
Other Website Code:
RewriteEngine On
RewriteBase /
# Redirect if the referrer is source29.medium.com
RewriteCond %{HTTP_REFERER} ^https?://source29\.medium\.com/ [NC]
RewriteRule ^(.*)$ https://www.example.com/destination1 [R=301,L]
# Redirect if the referrer is www.linkedin.com
RewriteCond %{HTTP_REFERER} ^https?://(www\.)?linkedin\.com/ [NC]
RewriteRule ^(.*)$ https://www.example.com/destination2 [R=301,L]
# Redirect if the referrer is www.facebook.com
RewriteCond %{HTTP_REFERER} ^https?://(www\.)?facebook\.com/ [NC]
RewriteRule ^(.*)$ https://www.example.com/destination3 [R=301,L]
# Redirect if the referrer is www.twitter.com
RewriteCond %{HTTP_REFERER} ^https?://(www\.)?twitter\.com/ [NC]
RewriteRule ^(.*)$ https://www.example.com/destination4 [R=301,L]
# Redirect if the referrer is www.tumblr.com
RewriteCond %{HTTP_REFERER} ^https?://(www\.)?tumblr\.com/ [NC]
RewriteRule ^(.*)$ https://www.example.com/destination5 [R=301,L]
# Redirect if the referrer is www.pinterest.com
RewriteCond %{HTTP_REFERER} ^https?://(www\.)?pinterest\.com/ [NC]
RewriteRule ^(.*)$ https://www.example.com/destination6 [R=301,L]
# Force HTTPS and www
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
# Rewrite URLs to index.php
RewriteCond %{REQUEST_URI} !^/(robots\.txt|sitemap\.xml)$
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
Replace example.com with your actual domain name and destination1 to destination6 with the desired destination URLs or pages for each respective referral address.
In this example:
Each referral address is checked using %{HTTP_REFERER} and matched against the corresponding regular expression pattern.
If the condition is met for a specific referral address, it performs a redirect to the specified destination URL or page.
The subsequent rules handle forcing HTTPS and www, as well as rewriting URLs to index.php for handling routing within your application.
Please note that the .htaccess rules provided are examples, and you may need to adjust them according to your specific requirements and server configuration. Additionally, ensure that you have mod_rewrite enabled on your server for the rules to work properly.
Comments
Post a Comment
Thanks for your Comments.