I haven't found any solution to my problem with symfony and virtual hosts.
I have one website www.example.com and have routes that have different contents based on an id.
Example:
www.example.com/id/1 is one website with menus that point to subpages:
www.example.com/id/1/page1
www.example.com/id/1/page2
www.example.com/id/1/page3
what I want is to set a new domain that points to this website with id 1 and another domain that points to id 2, etc.
For example:
www.newdomain.com shows content from www.example/id/1
www.newdomain.com/page1 shows content from www.example/id/1/page1
www.newdomain.com/page2 shows content from www.example/id/1/page2
www.differentdomain.com shows content from www.example/id/2
www.differentdomain.com/page1 shows content from www.example/id/2/page1
...
First of all, you just have to point both virtual host configurations to the same folder to make both URLs work.
But the virtual host setting is just one side of the configuration. You won't be able to configure the actual behaviour of the application regarding the different incoming URLs. I don't know if this can also be achieved via .htaccess settings, but you can definitely check in the controller of your application from what URL the request was send and then forward the user accordingly.
Related
A website example.com has one subdomain a.example.com. The point here is I want to redirect all existing and non existing subdomain (ex- b.example.com) to example.com without changing URL(URL MASK). To explain it more further, when a user enters b.example.com he must see example.com on his screen but URL must not change from b.example.com --> example.com. I think its possible from .htaccess file but I failed to achieve it.
Do I need to configure virtual host. Since I only have access to .htacces, I wish I can get it done
You need to have two things configured correctly:
A DNS entry with wildcard (*.example.com -> your server IP)
A virtual host with wildcard alias (ServerAlias *.example.com)
Then there is nothing to do in .htaccess. .htaccess alone can't do what you want. And please note also that this could be SEO-toxic (duplicate content), but it depends on your use case.
As you do not have access to virutal hosts config, may be you could go with subfolders instead of subdomains.
I have bought a domain and I want to redirect it to a directory on another subdomain.
Exemple:
A user type www.firstweb.com in the URL bar and he has to be redirected to www.secondweb.com/directory/ but the URL shown has to be www.firstweb.com without iframe.
Other exemple:
www.firstweb.com/contact/ shows the content of www.secondweb.com/directory/contact.php but the URL shown has to be www.firstweb.com/contact/ even after the redirect.
Both domain and servers are hosted by the same company (OVH).
I don't know if it is understandable but I dont know how to figure it out.
Thanks a lot for your help.
J.ROX
You can do this by installing NGINX (http://nginx.org/) on the webserver. Then you can check from which base URL the user is coming from, and return the appropriate content. This is also possible with an Apache server using Virtual Domain Names.
Or you can setup your DNS correctly, this can be done by your domain provider.
basically i have my website under 91.xx.xx.76/mywebsite in folder /var/www/mywebsite
and i want the user to type www.mywebsite.com, i have search some methods in doing so but doesn't actually solve it. they say to create a file under sites-available then enabled it
i have created file under sites-available and also enabled it using a2ensite mywebsite, then restarted apache2 using service apache2 restart then i try to load www.website.com but it loads nothing..
any help?
thanks
To use "name based URLs", you need to register the domain you wish to use in the global Domain Name System (DNS). Just setting some configuration in your own server is not enough; anybody could do that, which means there could be any number of people claiming the domain www.website.com at the same time. That's not how it works.
Find yourself a domain name registrar whom you'll wire a small amount of money in exchange for registering your desired domain. This purchases you the rights to set the DNS configuration of said domain to point its A record to your server's IP address.* This is what enables you to resolve www.website.com to your server. Then you only need to configure your server appropriately to serve requests for www.website.com.
* More correctly, it purchases you the right to set the NS record of the domain to point to a name server you control on which you can set any number of DNS records you want, including the A record. Most registrars also offer a name server as part of the deal of purchasing a domain, but those are actually separate things.
I want to automate a process so that my clients can sign up on their own to my application, insert them own domain name and i can map the domain name to their subdomain.
For example, they have a subdomain called mappable.example.com and they have a domain name called mappable.com
I have two questions:
1. How do you create a subdomain for them in php and/or nodejs called mappable.example.com
2. How do you map the domain name to mappable.com
I'm using nginx as a web server. Do I have to use php or nodejs to manually edit the nginx config files?
I'm assuming you own example.com, they own mappable.com, and you want to allow them to use their domain mappable.com to access your subdomain mappable.example.com hosted on your server.
There are a few steps you'll need to do for this.
Set up wildcard DNS with your domain registrar so that all sub-domains will come to your one server.
Set up wildcard domain handling in nginx's conf on your one server so that all requests are sent to your code. You can do this using an underscore as the server name to make it the default server.
In your PHP code, you can check the headers to determine what domain the request is coming in through. Do a dump of $_SERVER to see what's in there. You will then know if the request came to mappable.com, mappable.example.com, etc...
Once you are in PHP with the domain or subdomain that was requested, you can act accordingly. You'll want to store the mapping of domain to subdomain in a database most likely. Additionally, you'll have to tell your users that they need to set up a cname, for example a cname of "mappable.com" to "mappable.example.com".
I think that should do what you need.
I installed OpenScholar in my domain:
http://scholar.web
Basically, when someone register for an account, his site URL is http://scholar.web/user, and his content will be at http://scholar.web/user/contents
I've been searching a way so that the URL is converted into: http://user.scholar.web/content for displaying his content via virtual subdomain (htaccess maybe)
Anyone can provide some solutions or guidance?
thanks
First of all, you'll need to change the DNS entry on the domain so that *.scholar.web points to your site.
Afterwards, (If you're using Apache) change the Apache vhost to accept *.scholar.web requests.
You can then use htaccess and/or PHP to do what you like with the URL formatting.
I used to have a domain called something along the lines of "iscool.com".
This is the method I used so I could use pseudo subdomains like "ben.iscool.com" and it would display content accordingly.