The Most Active and Friendliest
Affiliate Marketing Community Online!

“Propeller”/  Direct Affiliate

Someone may need this small redirect script

istanbul

New Member
affiliate
Redirect Script

PHP:
<script>
function redirect(URLStr) { location = URLStr; }
redirect("YourURL");
</script>

-Add this Script to HEAD of your page
-Replace "YourURL" with URL where u want to redirect your page to..
I know its small thing but i just want to share it..
 
thank you for sharing this, but there is some problem with this script. As i can judge it is written in javascript which can not be followed by search engine robots, hence it may be cause to get your penalized due to the cloaking. I rather suggest php or htaccess permanent redirect instead of javascipt.
 
thank you for sharing this, but there is some problem with this script. As i can judge it is written in javascript which can not be followed by search engine robots, hence it may be cause to get your penalized due to the cloaking. I rather suggest php or htaccess permanent redirect instead of javascipt.

Thanks a lot but i am not that expert sorry. I used it for a web site and redirect it to another (Easy way)

But Ask me about diamonds thats my job :)
 
Istambul, there is absolutly no problem i just wanted to draw your attention to the possible disadvantage of the javascript redirection.

Well i had no touch with diamonds so far:)
 
Zoltan (that's your first name, right?), if you cold write samples of php and mod_rewrite redirects so we can have all 3 variations in the same thread?

Thanks a lot!
 
Of course SkinnerW. If you want to redirect page to the new location you may use php in order to let search engines know about the change. Here is a sample code:

PHP:
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.this-is-the-new-location.com" );
?>

If you have the possibility to use .htaccess redirections -the mod rewrite apache modul is enabled- you may place this code into the .htaccess file and upload to the root folder


If you have a complete website moved to a new domain you may want to redirect the whole website using this code as the part of the .htaccess file

 
To remove the www from your domain (to match your setting in Google Webmaster Tools):
Code:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com
RewriteRule (.*) http://yourdomain.com/$1 [R=301,L]
And if you want to redirect TLDs to your main one:
Code:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.(net|info|org|name)
RewriteRule (.*) http://yourdomain.com/$1 [R=301,L]
 
And if you want to redirect TLDs to your main one:
Code:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.(net|info|org|name)
RewriteRule (.*) http://yourdomain.com/$1 [R=301,L]

MArtin, i have never seen this code before, thanks for sharing. I guess it will work only if you own those TLDs.
 
I have learned about this code the hard way. Someone had hacked into one of my sites and added those lines to the top of some pages. People kept getting redirected to other pages.
 
Hi Martin, I have been using PHP redirects all the time since I am not good in my Regex codes for doing .htaccess redirects. I was wondering if you can modify the code you have and also redirect URLs with the "/index.html" to "/" only without causing an endless loop.
 
Here's how to remove the index.* - without looping:
Code:
# take out the index.php in URL...
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(php|htm|html)\ HTTP/
RewriteRule ^(([^/]+/)*)index\.(php|htm|html)$ http://%{HTTP_HOST}/$1 [R=301,L]
 
MI
Back