I've three domain names ex: domain.com, domain.p and domain.co.united kingdom. The com domain is really a global (primary) domain and also the other medication is country specific domain names. I must redirect the co.united kingdom and also the .p domain to domain.com/p/ and domain.com/united kingdom/.

What's the easiest method to do that on apache? Using rewrite rules in htacess file? or using php? Is it more beneficial to perform a 301 redirect (Search engine optimization smart)?

Just reply's.

Certainly the easiest way is by using 301 redirection. This really is adviced by google. Something similar to this in htaccess should work:

    Redirect 301 / http://world wide web.example.com/

it is best to get it done on server level, not application level (apache rewrite rules than php). For the reason that it will likely be faster, which is server's role, not application's.

However for those who have one htaccess apply for all domain names, than you might like to use conditional statement, something similar to:

    RewriteCond % !^www.example.com

    RewriteRule (.*) http://world wide web.example.com/$1 [R=301,L]

Which works 301 redirection always, once the current domain isn't world wide web.example.com. Take note, that example.com and world wide web.example.com are two various things! which means you make the decision which you want to use (without or with world wide web) and go for this.

Use apache's rewrite module. There's you don't need to run php interpretator.

301 ought to be used here but search engines like google won't index related domain names.