1

I have seen in many website like wordpress or wix or something same. They provide the service like xyz.wordpress.com where xyz is desired name.

How does i achieve it with my url for any user, like emma.crunchyfashion.com

I can do crunchyfashion.com/emma but don't know the above one. please suggest only the auto process.

Bob Arnson
  • 21,377
  • 2
  • 40
  • 47

3 Answers3

2

Try this .htaccess

it will rewrite anything.crunchyfashion.com to crunchyfashion.com/anything

RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+)\.crunchyfashion\.com$
RewriteRule ^/(.*)$   http://www.crunchyfashion.com/%1/$1 [L,R] 

Now, if you open anything.crunchyfashion.com it should redirect you to crunchyfashion.com/anything. You will still have the problem, that the redirect is visible in the URL address bar. In order to prevent this, enable mod_proxy (and load the submodules) on your server and exchange the "L" flag with the "P" flag:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+)\.crunchyfashion\.com$
RewriteRule ^/(.*)$   http://www.crunchyfashion.com/%1/$1 [P,NC,QSA]

If you have any further query on achieving this kindly make a comment here .

Further Reference :

1).htaccess rewrite subdomain to directory

2)http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

3)http://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_p

Hope this helps you

Community
  • 1
  • 1
Raja Gopal
  • 1,845
  • 1
  • 17
  • 34
0

You need to create subdomain for your website to create emma.crunchyfashion.com.

For example if you are running your website on wordpress then by following below steps you can create emma.crunchyfashion.com.

Once you have the correct CNAME, in your WordPress.com domain:

  1. Add the CNAME record to your domain.
  2. Go to your Domains page and click the domain you wish to edit.
  3. Click Name Servers and DNS, then DNS Records.
  4. Click Add New DNS Record.
  5. In Type select CNAME. Enter the correct CNAME in Name.

https://en.support.wordpress.com/map-subdomain/

https://en.wikipedia.org/wiki/Subdomain

himeshc_IB
  • 853
  • 4
  • 10
  • Wordpress does this automatically, How ? – Emma Miller Oct 12 '16 at 07:52
  • No wordpress doesn't do this automatically. check out reference links please. – himeshc_IB Oct 12 '16 at 07:52
  • I have created some url their many times. It doesn't take anytype of confirmation from their side. it does asap. – Emma Miller Oct 12 '16 at 07:53
  • Without an auto process it cannot possible. – Emma Miller Oct 12 '16 at 07:54
  • You need to create subdomain from your cpanel which will point to subdirectory on your www-root directory which will have all pages you want to show for emma.crunchyfashion.com. – himeshc_IB Oct 12 '16 at 07:57
  • himesh it is the possible answer, but I don't want to achieve this manually, please suggest me the auto process. – Emma Miller Oct 12 '16 at 07:58
  • Then you might have option to install one of below wordpress plugins to show as subdomian.. subdomains[link](https://wordpress.org/plugins/subdomains/) wp-super-subdomains[link](https://wordpress.org/plugins/wp-super-subdomains/) main-category-as-subdomain[link]subdomain(https://wordpress.org/plugins/main-category-as-subdomain/) page-as-subdomain-lite[link](https://wordpress.org/plugins/page-as-subdomain-lite/) – himeshc_IB Oct 12 '16 at 08:10
  • @Emma, stuck at any point ? or go through above plugins which might help you out to setup subdomain through auto process.... – himeshc_IB Oct 12 '16 at 09:34
0

though your question is not very clear, but for you to achieve this, for me.mysite.com, "me" is a lcoation on your root directory and its a subdomain. So if your question is on how to create subdomains, log into your cpanel or web host admin portal and locate the section for subdomains. in php you link it as a normall link. eg

<?php 

$myLink = "http://me.mysite.com";
echo $myLink;

?>
Francis Sunday
  • 77
  • 1
  • 11