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.
Related
There is a running website (on Bitrix CMS) located on the simplest shared hosting with cPanel. The task is to create a standalone little web application in PHP (for internal use in the company), which, for simplicity, will be available from the same domain, but, what is important, it will not affect the already running site.
On the hosting, in the file manager, there is a public_html folder - as I understand these are the site files. I created in public_html a subfolder (for example, webapp) and added a couple of test files (for example, test.txt). The test file is supposed to be available at site.com/webapp/test.txt, but nothing is loaded - just a white screen, no error messages.
Trying with text files and simple php-scripts - the same result, just white screen.
How to fix it?
Check your .htaccess on site root, it maybe redirecting all routes to index.php of Bitrix CMS.
Alternatively you can follow above answer and create a subdomain.
Simple tutorial here.
You can create a subdomain and point your public_html folder there.
You need to create an Index.php file in the subdirectory, in hosting any folder must have this file which will be executed any time you access that directory with URL.
I have just created a simple REST Api following this small video using Slim Framework 3.x. I was just getting started and I followed the instructions in the video and created a simple route like this
$app->get('/', function($request, $response)
{
return 'Home';
});
This works on localserver (XAMP) when I open the link `
localserver/project_name/public/
` I get "Home" returned on the page.
After that I simply Zipped the project folder and uploaded it to my Web Hosting, htdocs folder. I extracted the zipped project, which included the "composer.phar" and "vendor" folder. I try the same thing again, i.e., I run the url
www.mysite.com/project_name/public/
All I've done is change "localserver" with www.mysite.com but the browser tells me that my domain
is currently unable to handle this request.
I know this might be something very obvious but I am a novice in php and REST Api's. So any help is appreciated. Also some things I think might matter are, The web hosting that I am using is Plesk based. I have a mysql database Running on the hosting and simple php files run when run individually. For example if I run simple call a test.php file with some database query in it and some echo, it will run successfully. Even if you can point me in the right direction, I would appreciate it. Oh, and I don't have access to php.ini on the hosting. I was only provided with one login that lets me login to the hosting and I can see htdocs folder among some others. I have attached an
image of the view I get after logging in, to give you more perspective of the type of hosting I have. I am hosting a website in the httpdocs directory as well. ASP.NET developed
I just need some direction as to what I need to do to be able to publish my REST api to my hosting and be able to access it through this android app that I am building. What do i need to do on my server? What settings to change to make the api work?
I have over the past months tried to learn myself about php/laravel. I have made some laravel hobby apps which i was thinking of putting on a server, so i could use them.
I am using digitalocean for the server and laravel forge for easy deployment.
My problem is that on laravel forge it says that i can add sites, but how do i add more than one site?
There is three fields to fill in: Root Domain, Project Type and Web Directory. What do i type in these fields and how do i access the site afterwards?
Root Domain: This is the domain (web address) that you want to be associated with your site (e.g. example.com).
Project Type: This is the type of application that you're wanting to be hosting. In your case it will be General PHP / Laravel.
Web directory: This is the folder of your app that you want to use as the web root. In your case this should be public/ (unless you've moved/renamed the directory or you've moved you index.php out of that directory which I don't recommend). It is generally good practice to have your web root in a sub directory so that you can easily prevent access to sensitive information by placing it in the root directory or you app.
With a Laravel site you should almost always only have to fill out the root domain field as the rest are set for Laravel by default.
Forge comes with a "default" site set up so that you can access your site with just your ip address of the server, however, if/once you've got your domain it is recommended that you delete this and then add your site/app with the domain.
To add another site you would just need to:
Point the A record of your domain to the IP address of your forge server
Fill out the form for adding a new site (in Forge)
On the next page set up forge to pull your app from your git repo.
This tutorial should give you a quick overview: https://laracasts.com/series/server-management-with-forge/episodes/13
It is part of a series should you want/need more information but please note that some of the videos are over 2 years old so some minor things might be a bit different.
Hope this helps!
I'm trying to migrate our Magento to Amazon Cloud.
Currently we have this setup:
www.xyz.com (/var/www/vhosts/xyz.com/httpdocs)
This is where Magento is setup:
www.abc.com
This is where our Wordpress is setup:
www.abc.com/store/
This is a multi store setup to use the code in xyz.com with index.php calling the Magento app.
Initially, I was thinking of using 1 EC2 instance for Magento and another EC2 instances for the Wordpress. Then I would setup 2 Elastic IPs to the 2 instances and then point abc.com and xyz.com to their EIPs accordingly.
However, I can't think of a way for the /store/ folder under abc.com to use the same source code for Magento.
Could anyone advise?
Thanks.
I'm not quite sure about your needs but I would recommend to have store.abc.com as subdomain - this way you can link xyz.com and store.abc.com to the same folder and keep abc.com to the main wordpress folder. But again need to look deeper into the setup. we just transferred one of the store to amazon AWS.
Your only option is a Proxy. Everything else (Like mod_rewrite / Alias) will do a header redirect, and expose the target address to the user.
However, Apache's proxying doesn't seem to be that complicated. The most basic example is
ProxyPass /mirror/foo/ http://backend.example.com/
Note that a proxy will of course double your traffic, because every byte requested will have to be fetched from the remote machine.
Source: Sub Directory to a different server
I have a web app of which I would like to create a mobile version with jQuery Mobile. The existing application is built in CodeIgniter; I'll be using the same controllers, models where I can; (especially models since I'll be needing the same data anyway, might have to write new controllers).
I'm a bit confused as to how to get started. I want to put my mobile version on a subdomain (m.myhost.tld), however.. since my app is at www.myhost.tld and I don't feel like copying it all over to another folder and maintain two, I'm a bit confused.
I know I can use the User Agent library in CodeIgniter to detect mobile browsers and load views accordingly; I just don't know how to get this working with a subdomain. Do I need to customize my app/config/routes.php file here, or can I fix this with some .htaccess magic? I have next to none experience with .htaccess though. The only thing I know is how to remove my index.php from CI apps, and that's a copypasta snippet.
EDIT: I wonder if I can use a tutorial like this one to do what I want to do? It seems to be doing more or less the same thing, just with dynamic usernames instead of a simple 'm.'
EDIT 2: Some more information, I guess.
Say I detect mobile browsers using the User Agent library included with CodeIgniter. I want to direct these browsers to m.myhost.tld. However, the content that I want to display on the mobile website comes from a controller called mobile which I can also access through www.myhost.tld/mobile/; so my question is if there is a way to route a URL like.. for example www.myhost.tld/mobile/about to m.myhost.tld/about. I'm not even sure if this is possible, teehee. Still learning!
I'll be grateful for any advice you can give me. Thanks a lot!
If you want to share the same files in different hosts, you must assign the document root folder of your sites in your web server, this is an explanation for static files, but is the base to you understand.
browser -> host:z.y.xxx[ip.ip.ip.ip] -> web server -> read filesystem : document root + browser request path
so if your document root is:
/hosting/http/z.y.xxx/htdocs
and the request is /path-to-static/index.html the server try to read:
/hosting/http/z.y.xxx/htdocs/path-to-static/index.html
In conclution, you create the new host m.mysite.tld in your web server and you change the document root as the same of the you www.mysite.tld also you could use directives of host alias, like Apache ServerAlias directive. Have lot of documentation to how you could configure a web server.
You could handle the host name in php with $_SERVER['HTTP_HOST'] variable.
If you could specify more, I could help more.
have a nice day