I have a website with multilingual support which you can access with virual subdirectory.
For example:
www.domain.com/ru/
which is actually
www.domain.com/index.php?lang=ru
(i'm doing it with .htaccess).
Since I decided to host every language in a different host, I need to make the site use subdomains instead of subdirectory.
However i'm kinda lost here.
I tried to create a subdomain (I use DirectAdmin) and than use .htaccess to do the same thing I do with the subdirectory, but for some reason when I go to ru.domain.com i'm redirected to www.domain.com/index.php?lang=ru...
Thank you very much,
Yolei
Related
I have a WordPress website that is hosted using NGINX. I do not have any root access. Their system allows me to point multiple domains to one WordPress site. When you visit the 2nd domain, their hosting rewrites it to the primary domain name. I am unfamiliar with NGINX, but I am assuming it is similar to an Apache rewrite rule.
The only thing I have permission to do is create a custom plugin and install it. So I can use PHP or WordPress' own actions. But I would like to catch when the original request comes through using the 2nd domain so that I can then do stuff.
Is there a way to do that?
Thank you.
With my current PHP knowledge, I know how to create a subdomain automatically via Plesk api when a user is created on my site. I can then redirect the user.example.com to example.com/user via htaccess.
My question that I cannot figure out how to do, is how to redirect but also keep user.example.com in the navigation bar, not the example.com/user ?
I own a dedicated hosting environment so I have access to change pretty much any setting that I like.
Here are some suggestions:
Don't use .htaccess for this. A very common use of .htaccess is to redirect all requests to a central file (generally index.php).
In order to allow dynamic subdomains you need to make sure your virtual host is configured properly for that.
And in order to redirect to the subdomain url you can use the built-in php function header.
Example:
header('Location: '.$subdomainUrl);
I'm trying to improve my skills in PHP by creating my own CMS infrastructure, probably based on a lightweight framework like FuelPHP.
Because I think it's better to have a goal, I would like to use this opportunity to build a multi site CMS.
It would be a CMS for a game.
Basically, here the workflow:
Somebody create an account on the main site (http://www.mainsite.com), then create a site for his server (http://my-beautiful-server.mainsite.com). People from his server would then come to the subdomain and register to interact with the forum, the gallery, updating their account, etc.
Is using subdomains a correct approach ?
If I use a wildcard for my DNS, how must the vhost be configured to redirect on the correct folder based on the subdomain ? Can I not use a folder system for each site and use only one app to handle everything by just "passing" the subdomain as a variable to the app to tell it on which site I am ? Is it reliable ?
If in the future I want to propose custom domain names, is it possible with this approach ? I would only need to handle domain name registering myself and add a vhost configuration to redirect on the correct folder ?
I'm a little lost on the correct and most robust approach.
Today I have the domain name and I will take a little VPS for testing.
Thanks a lot for any help to guide me in the good direction and sorry for my broken english, I had trouble finding ressources on the Internet.
Is using subdomains a correct approach ?
It is a perfectly acceptable approach.
If I use a wildcard for my DNS, how must the vhost be configured to redirect on the correct folder based on the subdomain ?
You use a default vhost to capture all the requests for the different hostnames.
Then you can shuffle them around using mod_rewrite or by examining the requested hostname at the application level.
Can I not use a folder system for each site and use only one app to handle everything by just "passing" the subdomain as a variable to the app to tell it on which site I am ? Is it reliable ?
Yes.
The variable will already be available to your PHP via $_SERVER['HTTP_HOST'].
If in the future I want to propose custom domain names, is it possible with this approach ?
Yes. There is no practical difference between a domain name and a subdomain as far as a webserver is concerned.
I would only need to handle domain name registering myself and add a vhost configuration to redirect on the correct folder ?
You wouldn't even need a specific vhost configuration. Your default one would suffice.
I've tried solutions as such, but they don't see to address the problem Im at.
How to create a sub-domain in CakePHP?
I have a CakePHP app in publichtml/lastroarte.com running ok. I went to my DNS and created for a subdomain entries for sandbox.lastroarte.com a test subdomain for the new version of my which we'll be upload the new app.
If I browse to the subdomain now, it redirects me the home page of my domain, still displaying the url sandbox.lastroarte. I've found entries for the pages in the Routes file of Cake, although I have not found way to say a subdomain should display the index of its own folder (public_html/sandbox.lastroarte.com). Am I doing the right approach? How to achieve this?
Appreciate your answers.
(Assuming you are running apache as your web server)
You have created a sub-domain, but have you created sites-available and sites-enabled files and restarted apache?
If you are using your host's control panel it will do this for you, but you will need to associate your public_html/sandbox.lastroarte.com directory to the sandbox.lastroarte.com sub-domain.
In short this doesn't sound like a Cake routing problem, it sounds like apache is routing traffic from sandbox.lastroarte.com to lastroarte.com.
I'm trying to setup some rules for ExpressionEngine that will automatically make an entry accessible (and display) like a subdomain. The standard URL path for an ExpressionEngine entry would be:
http://mysite.com/post/entry.title
But I need it to be accessible and appear as:
http://entry.title.mysite.com
This only has to be for one particular channel and using one specific template group/template. It does have to be dynamic though, so that whenever a new entry is created, it can automatically be accessible at http://entry.title.mysite.com. I understand that this might be possible through a wildcard in .htacess but I'm not sure how to do this.
Search the Qs here for HTTP_HOST. Lots of examples which answer this generic Q :-) Note that how it works depends on how your hosting provider has configured the use of subdomains. Some always use the DOCROOT for all subdomains, some provide an admin panel to map them to subdirectories. You will need to find out which your host does from its FAQs.