php - How to make domain redirect? -


so make simple:

let domain greenexample.com. using domain, want make link:

greenexample.com/amazon321 

redirect to:

amazon.com 

without using meta refresh.

i want make multiple link re-directs this.

so how do in index.php, or need create new php file in file directory each link?

if so, php code so?

to php file, create index.php file in amazon321 directory following:

<?php header("location: http://www.amazon.com"); exit; ?> 

an alternative, , better way, use redirect directives in .htaccess file instead. (assuming you're on linux based server.)

redirect /amazon321 http://www.amazon.com redirect /amazon123 http://www.amazon.com 

you can fancier using mod_rewrite directives. example, capture criteria in url , pass on.

rewriteengine on rewriterule ^amazon/(.*)$ http://www.amazon.com/$1 [r] 

in example, after amazon/ found , replaced $1 is. "http://www.greenexample.com/amazon/12345" redirect "http://www.amazon.com/12345".


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -