How to automatically parse a subdomain with WordPress - php

We have a unique Wordpress installation and the front page is an iframe that needs to redirect to an address which depends on the URL it's being accessed from (more specifically, it depends on the subdomain).
Let's say, if the address is :
<subdomain>.<Domain>
then the iframe should redirect to:
<subdomain>.<OtherDomain>
ex:
chc.mynewdomain.com
should contains an iframe redirecting to:
chc.myolddomain.com
The questions are:
1- how to have all subdomains go to that unique wordpress install?
2- how to parse the subdomain in the underlying Wordpress (PHP) code, possibly check against a white list of subdomains, and build up dynamically the iframe URL?

To have all subdomains go to the same wordpress install:
first, setup a wildcard domain entry. procedure varies depending on the dns host
then setup a wild card entry in your httpd config (typically involves adding a * in hostname)
As for handling it in wordpress, depends what you are trying to do. The most likely scenario is you want a different page for every subdomain so you will have to enable wordpress multi site for multiple site. Then, you will have to install the domain mapping plugin. A url that describes that is here: http://wp.tutsplus.com/tutorials/wordpress-multisite-beyond-basics-essentials-and-domain-mapping/

Related

How to run Magento 2.3 on several domain aliases, but using only one website (and one storeview)

I need to create many different magento 2.3 shops as subdomains of the main shop;
eg shop1.domain.com, shop2.domain.com, shop3.domain.com, shop3.domain.com
All those subshops will share the exact same content, products and storeviews (content in different languages using subdirectories /en /fr /de etc) of the main domain and my goal is to not create a different magento website or magento storeview for each of such subdomains.
I'll customize just some graphic of the subdomains by loading a different theme/css based on the HTTP HOST env variable.
Can you tell me how to achieve this?
I've now configures nginx so that all the subdomains are mapped to the same document root, but when now I load a.domain.com I get automatically redirected to www.domain.com
Thank you!
I've found the solution: I had just to change the "Auto-redirect to Base URL" to "no" and it worked. Now I've to customize Base URLs, but at least I fixed the automatic redirect

Allow users to access their page on my site by using their own custom domain

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!

URL redirect to dynamic subdomain

I currently have a website (ab.example.com), where 'example.com' is the company's root domain. and 'ab' is a product's subdomain(website). Within the website (ab.example.com), I have multiple sub-products (gala, granny smith, fuji).
When a customer goes to ab.example.com/apples/gala I want them to be redirected as gala.example.com/apples. Similarly for any other sub-products I have. I understand that this is similar to .htaccess redirect to subdomain based on query string parameter, where .htaccess at the root folder is being used to add the redirect rules.
But does this mean that no changes have to be made in the cpanel or update dns entries for the new subdomains? I have also looked into the wildcard domain methood - Create subdomains on the fly with .htaccess (PHP).
I am confused about which method to use. I'm fairly new to php and its frameworks. The web application is in ,
php
Laravel
Azure
Apache
Linux(Ubuntu)

Wordpress looking in the wrong subdomain for wp-content

I have my wordpress installation at /var/www/html/wordpress2 and there's a totally separate wordpress installation at /var/www/html/html/wordpress.
When running the worpdress2 installation, I get errors saying it can't find /var/www/html/wordpress/wp-content/theme/.... How do I change it to look for these things in wordpress2 and not wordpress?
Did you transfer wordpress to Wordpress 2? If so you need two separate databases, one for Wordpress and the other for Wordpress 2. Then you need to check the wp_options table to have their correct subfolder in the site URL and home URL.
Follow these steps in order to transfer your WordPress site from one location to another.
Change the option_value(your root url of current wordpress site) corresponding to id(value 1) and option_name(value site_url).
Access your wp-admin(siteurl/wp-adimn). Go to general-setting panel and change Site Address (URL), same as WordPress Address (URL).
Hope this will work for you. Same process you can follow to move WordPress site from local to server or one server to another.

Building a SaaS application on Zend Framework

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

Categories