Generating sites from a single app all accesible with different domains - php

I need to create an application through which I can generate different sites. All these sites will have the same layout but each one will have different contents (texts, images, colors, etc).
The hard part is that these sites should be able to be accessed through different urls.
Let me give an example:
I log into the application from there I create a new site with the name FooBar and it may be accessed through the http://foobar.com url.
The same if I want a site http://foobaz.com. All sites may be generated and managed from the same administrator.
I have read about Wordpress multisite and I think maybe it could help me. If its not possible via Wordpress I can make it with some web framework like Laravel.
The main problem I cant figure out is how to map the domains with each site generated.

I think the right way to do this is to point all the domains to the same laravel app+routes so then in the controllers you can do the check of the domain the user is currently visiting and get the images and texts accordingly the domain from the DB.
In other words, make the logics on the controllers/helper level.

Related

How to pair non-generic custom URLs in a URL Shortener?

Our PHP web app has an integrated URL shortener with URL-Slug Customisation.
Users can already edit the example.com/somerandomstring part of their generated URLs into f.e. example.com/chosenstring.
However now we want to add complete custom URLs, meaning that instead of only customising the path (somerandomstring), we want them to be able to add their own, owned domains.
In other words they should be able to turn example.com/somerandomstring into theirurl.com/chosenstring
What are the necessary steps to consider here? Is there a trick to automise this effectively with PHP or another related language? Which DNS records will need to be set exactly?

How to make a URL for pages in my site that looks like this: http://www.example.com/username?

I'm building some kind of social-network site using PHP and mysql (and quite new to web development..). I want user profiles to be accessible trough the URL address as "http://www.example.com/username".
It is also very important to me that each profile page will be indexed by search engines.
How do I do this?
You need to use .htaccess - mod_rewrite to be more specific
You can find many resources online for this.

Trying to incorporate members area from one site into another

I am working on a website where I need to use the login form to log into a different site and then bring the member's area from that site over to the one I am building.
I have access to both sites and can make changes on either one. I would incorporate the code from the old one directly but it is in ASP and I'm working with PHP.
Any ideas? The purpose would be for someone to login to the site through site A (no problem) then get the information from site B (no problem) and present it in site A (no problem if I use cURL to get the site and break it up then display it on the new one). The issue I get into is the links that are on the new site and gathered from the old site will still point to links on the old site. Maybe there is a way to dynamically generate those pages on the new site somehow? Or am I going about it all the wrong way?
It's essentially a proxy. You need to parse and rebuild the links in the html source code received from site B. There are no functions available for this, but there are numerous open-source proxy scripts you can take code from.
Glype should be open-source (site appears to be broken now unfortunately).
https://www.glype.com/
You need to split the links to change them depending on where do they point.
Links to css/js should be rewritten to point to the real url (note that ajax content won't work, because you can't do an ajax request to another website)
Absolute links to the real website should be changed to relative
Relative links should point at your website (ex. $new_url = '/viewpage/?page=' . urlencode($url);)
Absolute links to other domains (not the old website that you proxy) should be dealt somehow, think about what do you want to do with them exactly.

ecommerce templates

I am currently working with a eCommerce site for a client but to keep things organized I am wanting to group some pages in sub folders. However, because of the nature of eCommerce it relies on several pages in its base folder (search.php, products.php, etc) to generate some of the pages of content and therefore I cannot really have any subfolders unless I make copies of all the necessary pages into each seperate subdirectory and then it makes everything more complicated not to mention creates issues of its own.
I hope my question is clear enough and I was wondering what options are in a situation such as this?
Is there a way I can setup a redirect page for each of these common pages inside the sub directory to redirect to the base files but maintain any POST data?
you can try store the filtered post values to session(preferred),cache,Database, or just include a php script into to the script in which you post the form data.

Codeigniter, domain to a certain area of the site

I'm not a very experienced programmer, and am using CodeIgniter for second time.
Suppose I have www.domain1.com. So I will have, say 3 controllers /area1, /area2, /area3. Users can access them as www.domain1.com/area1 etc. if I set the base URL as www.domain1.com. But my problem is, the client wants a certain area of the web, say area2, working as a microsite, in its own domain, so he wants to access area2 with www.domain2.com.
I don't know how to get this working with CodeIgniter. Suppose he registers www.domain2.com and set it pointing to the same DNS, server etc. How can I get CodeIgnitor to execute the controller area2 when the URL www.domain2.com is accessed?
Maybe changing $config['base-url']? Routing? .htaccess? Please, if you have solved this, examples of code involved would be greatly appreciated.
Edit: I will put example of the site I want to get.
I have one normal installation of CodeIgniter (external host, I can't access httpd.conf) It is on one machine, and the root of the site should be accessed by www.domain1.com
All domain are outside registered to. So I have the home controller, which shows me the main page view. And suppose the site have 3 areas /area1, /area2 /area3, with their correspondent controllers, showing these areas views.
My client want to emphasize one of the areas, the one that controller /area2 shows, and he want use a different domain for that area, www.domain2.com
What can I do so that when the user browse to www.domain2.com, CI redirects them to www.domain1.com/area2? Could I, for example, modify $config['base_url'] according the received URL, or is that impossible? Do I need to modify the .htaccess file?
After a lot of searching, I found a solution that seems to work, very easy to be honest:
Modify routes.php:
if ($_SERVER['HTTP_HOST']=="www.domain2.com") {
$route['default_controller'] = "area2";
}
No need for mod rewrite.
Here's a helpful link....
http://www.askaboutphp.com/88/codeigniter-setting-up-multiple-sites-on-one-install.html
Never actually done this myself, but this seems to be the way to go about it without having two ci installs. Good luck.
you definitely need to go the mod_rewrite way
the first solution that comes to my mind is to use Apache mod_rewrite, but as far as I know that would work only for internal redirects (i.e. resources residing on the same server/domain).
What about using an iframe? You could set up domain2.com home page with a full-page iframe that takes it's content from domain1.com/area2.

Categories