I have Symfony2.8 application installed on my server. To make things easier, let's assume that in /very-long-path/web directory. I also have domain for this directory - eg. example.com. Page at example.com is accessible by all my users. Application has also backend for admins at example.com/admin. I think this is common configuration for many webpages.
What I want to do is:
Buy second domain eg. admin-of-example.com.
Disable access to the example.com/admin (or configure redirect to admin-of-example.com)
Make backend for admins accessible only via this second domain.
Is it possible and how? I completely don't know how to do that? Probably mod_rewrite?
What may be important? Symfony base on fron controller, therefore example.com/admin not directs to real folder - there is no /very-long-path/web/admin directory. Frontend for users and backend for admins are parts of one application, therefore I cannot move backend to other hosting/domain physically.
You can restrict routes to be matched only when the request is for a particular hostname: http://symfony.com/doc/current/routing/hostname_pattern.html
Related
I'm building a PHP MYSQL based site builder based on smarty templates where each site would have a folder which would contain all the site files such as html, assets and scripts. I want to add a option for my users to add their domain name in the backend for each site, point a dns record to my server and be able to access their folder on the server via their domain name
For example their url on my site would be www.sitebuilder.com/sites/example/
Their domain: www.exampledomain.com
When someone visits this domain, the index.html at the url would be shown.
I hope this makes sense, How do i achieve this? Thanks!
I have main website on one domain and now I am working for m.domain.com (mobile sub-domain).
On my main website users register themselves and a directory is automatically created in website.
Now as I am working on different directory for m.domain, users register themselves and directory is created in m.domain, but it is not created in main website. So i am stuck.
I want to have common user's directories even when they login from main domain or m.domain.com
Here's image:
Do not use different directories for your domains.
You have (at least) two options:
configure your web server so that both domains (domain.com and m.domain.com) point to the same directory (e.g. virtual hosts - refer to your web server documentation)
configure URL redirects, so that any m.domain.com/page.php actually opens domain.com/page.php?mobile=1, where mobile=1 is a GET parameters.
In both cases, you have one set of PHP scripts, and the script can deliver the main/mobile content dependent on how it was called (either m.domain.com or due to a mobile GET parameter).
I don't know if it is even possible so that's why I put my question here.
We have a webserver running a PHP application build within the Yii-framework and we have also integrated Wordpress into that application.
The root contains the Yii-application and a dir with the wordpress installation. Now I would like to know if it's possible to create a page and have it a url outside it's installation dir.
An example:
domain.com shows the Yii application index
domain.com/blog shows the Wordpress homepage
Now I want to create domain.com/foobar and the page foobar comes from Wordpress.
Is it possible and how?
Kind regards,
Pim
Your server will have been setup with your domain name. I don't know if you are using a hosted service, or a cloud based option, but either way you should be able to tell your web server to load different index.php files based on the URL.
Every single web request comes through your web server. You can tell your web server to load different php files depending on the http request URL.
For example, when you setup your sever with domain.com you would have had to (or in most cases its the default) tell your web server to route all domian.com requests to /public/index.php
Following this logic, if you want to load a different index.php file from a different URL, you just have to set this up in your web server. So domain.com/foobar would point to /some/directory/public/index.php
The way you do this very much depends on your server and if you have some server admin software installed e.g. cPanel.
I have a multi-tenant SaaS platform and a customer wants to customize the look and feel of the login page and the dashboard page. I was able to successfully customize the dashboard page by storing the name of the CSS file to use in the ACCOUNTS table of my database. This works because I know which account to get from the database once they log in. However, I do not have this capability for the login page.
Is it possible to customize which CSS file or login page to use based on the DNS? For example, customerabc.server.com gets the generic login page. customerxyz.server.com gets their custom login page.
I am using Apache and PHP. Thanks.
Yes just configure an apache subdomain to the same docroot and react in your application on the different domains.
I was able to do this using apache vhosts. The ServerName property needs to match the root URL/URI and to ensure that all includes are being set properly, You have to have a copy of the php.ini file in the root directory so that you can make changes to the include_path here and not affect other install instances elsewhere.
I am on the way of building a SaaS application using Zend Framework on PHP. Here is the basic information of the project. Its Project Management System on SaaS model. When the user registered on the site, they will get a domain name like the format:
user_name.pms.com
user_name - The chosen User Name when the user registered on the Project Management System (pms)
pms.com - is the main SaaS Server.
Currently we provide the Sub Domain on our Server. And for big firms, it won't look good and they may prefer to get their own domain instead of this default one. So there may be:
user_name.pms.com [Always Present]
user1.com [ The custom or independent domain of the User ] This custom domain needs to link into the default user url.
The full website is planning to develop using Zend Framework.
On Zend Framework, we are having following HTAccess on the root folder for its working and is below:
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteRule .* index.php
Here are my questions:
Do I really need to create Sub Domain like profile url for all users once they registered on the site ?
If it need to create Sub Domains, can PHP check whether the chosen sub domains exists or not and can create Sub Domains from the Script itself ?
If there is no need to Sub Domain, can we achieve the same goal using HTAccess in Zend Installation ?
Can you provide the HT Access code which does the following:
"user_name1.pms.com" need to redirect to "pms.com"
"user_name1.pms.com/contact" need to redirect to "pms.com/contact"
ie any request on the Sub Domain like URL must redirect to main website with the format: pms.com followed by Query String.
Very Important:
Important 1:
When I said the redirect to main website, I need to keep the sub domain like URL on the address bar but the request will be served by main website.
ie "user_name1.pms/contact" is going to be served from pms.com/contact but on address bar we still see the url "user_name1.pms/contact"
Important 2:
Whenever we uses the HTAccess to redirect the request to main Zend Server, can I identify the actual url entered on the address bar ie "site1.pms or site1.com" ?
Another Question of Custom Domain Redirection:
The custom domain name like "site1.com" or "site2.com" need to redirect to either:
Option (a): "pms.com"
Option (b): "site1.pms.com
to serve the request. Here also, I need to keep the url on address bar same like the one user entered.
Which above option is better (a) or (b) ?
Which technology does this work, domain mapping or CName ? Or Any other technology for make this working.
There are several ways to get you at least near to what you want... but to get all of the way there, you're going to need to get a little more depth.
First of all, your questions:
You may need to actually set up a whole virtual host for each user, if you intend for them to be able to interact with your site through their own domain. If you just want them to have their domain redirect to yours that can be done at their registrar (and if they can successfully use masking, which I've always found problematic, it may work completely without doing this. If you ignore the custom domain requirement, then you can manage subdomains completely through mod_rewrite without having to actually set them up.
Probably the best architecture for your site is to proactively set up whatever needs to be set up the moment that the user signs up. Don't try to do it "just in time" when the user first tries to access it, and therefore it's just as simple as displaying an error when someone, say, types in usre.pms.com rather than user.pms.com.
You can use htaccess, or the config file for your site (which is better for performance, but just strictly for "getting done" purposes, htaccess will work fine).
Google
Very Important Point #1: this is how mod_rewrite works. No worries.
Very Important Point #2: yes, so long as you include that information to be passed along in your mod_rewrite rule
Your Last Question of Custom Domain Redirection:
This is where things get complicated. You can't serve site1.com from pms.com without apache being fully aware that it's looking for site1.com (unless you get forwarding with masking to work without issue at the registrar). Generally speaking, if you're using forwarding of some sort, then you'll want them to forward to the subdomain, and all will be good completely through mod_rewrite. If they are directing the domain straight at your server, a CNAME record is probably the right choice, directing to the subdomain, but you'll still have to learn about virtual hosts and how to properly set it up to get everything to work.
I think you may be signing on for more than you realize by letting your clients have their own custom domain. You can learn how to do what you want with subdomains probably in an afternoon or a couple days tops. Figuring all of the ins and outs to working with custom domain names could take a lot longer.
The sub domains can be handled using some technique in CPanel. To add vurtual sub domains from CPanel, do the steps:
Select "CPanel - Sub Domains"
Enter star and choose your domain name
Choose the directory to which you need to redirect
And handle the redirection from your page.
To develop a SaaS application using Zend, check the tutorial SaaS application development using PHP in Zend Framework