One host, two domains, two websites - hosting

So I want add second domain. I have website that uses domain1.com, but I want to add domain2.com which will show page from domain1.com/domain2_web/
I added domain at cpanel, but when I am going to domain2.com it redirects to domain1.com/domain2_web/
Is it possible to show domain2 website using only domain2.com ?

If you access to the raw Apache .conf file, you can set up a virtual host that has a seperate DocumentRoot.
<VirtualHost domain2.com:80>
DocumentRoot .../domain2/
</VirtualHost>

Related

pretty-urls not working with XAMPP and Laravel 5.8

I use Laravel v5.8 and I was happy to use it in VMware with Ubuntu. Now I needed to change to a Windows Server 2012 with xampp.
There is one thing I cannot eliminate:
I can visit my page over
https://fancysubdomain.fancydomain.de/myapplikation/public
I've created links like
<a class="title" href="/entries/create" > FOO </a>
These links go to
https://fancysubdomain.fancydomain.de/entries/create
(watch the missing "myapplication" block) and Apache tells me that the requested URL was not found.
If I type
https://fancysubdomain.fancydomain.de/myapplikation/entries/create
in the address field of the browser it also doesn't work.
In the .env file, I've set
APP_URL= https://fancysubdomain.fancydomain.de/myapplikation/
I've edited \conf\app.php to
'url' => env('APP_URL', ' https://fancysubdomain.fancydomain.de/myapplikation/'),
There are no virtual hosts set up in httpd-vhosts.conf (I am not the administrator). Do I need to set them up to get what I want? Do I need to set up something else?
You should create a Vhost which should point to the public directory of you Laravel application.
It should look like this:
<VirtualHost *:80>
DocumentRoot "path/to/laravels/public/dir"
ServerName localhost
<Directory "path/to/laravels/public/dir">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
After this is done, the default .htaccess file will work and you have pretty url's.
I’ve finally found a solution. Thanks #J. Grunder stackoverflow
After I had changed these settings, I ran into a new problem with my links.
I had created links like
<a href=”/entries/create”>Create Entry</a>
Unfortunately, now the links pointed to
https://fancysubdomain.fancydomain.de/entries/create
(watch missing myapplikation element)
Of course, I could handle that with
<a href=”/myapplikation/entries/create”>Create Entry</a>
But there could be some problems if the user is at that place.
If somebody else runs in the same problem:
Use Laravel’s URL helper:
<a href=”{{ action('EntriesController#create') }}”>Create Entry</a>

how to configure dynamic urls in httpd.conf file for reverse proxy

I am using apache httpd server for reverse proxy to make cross domain ajax calls.
ProxyPass /v1/virtuals http://mypage.com/:4277/v1/virtuals/abc
ProxyPassReverse /v1/virtuals http://mypage.com:4277/v1/virtuals/xyz
in the above url the abc,xyz will be changed based on the selection.those will be dynamic.so how could i configure the urls with that dynamic content in httpd.conf file
Tried with wild card pattern. but it is not working.
http://mypage.com/:4277/v1/virtuals/
in httpd.conf is sufficient to allow all the urls

When people say "subdomain" do they mean VHosts with similar names, or mod_rewrite mappings?

I'm trying to set a cookie for use across different virtual hosts. Something similar to this has been asked multiple times here:
Cookies in subdomain doesnt work
how to access cookies on subdomain
Cookies And Subdomain
Setting cookies on domain/subdomain
cross subdomain login with cookies
Cookies and subdomains
They all mention a 'subdomain' but none describe what that is. If I have 2 Apache VHosts like so:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/
...
</VirtualHost>
<VirtualHost *:80>
ServerName home.example.com
DocumentRoot /var/www/home/
...
</VirtualHost>
If I log the user in at example.com and set the --and make sure to say the next word in a deep cookie monster voice-- cookie like so
setcookie( 'id', '1234', time()+24*3600, '/', '.example.com' );
Can I get id at home.example.com like so:
RewriteCond %{HTTP_COOKIE} \bid=[0-9]+\b
Or do these cross domain cookies only work when the subdomains are set up entirely within a single virtual host (presumably with mod_rewrite)
It's entirely based on the domain name. The same-origin check doesn't care about the underlying IP.
home.example.com could be:
The same as example.com
Different
Your local box
A subdomain set up by an attacker using DNS forgery.
It doesn't matter. It's still a subdomain.

2 joomla sites in the same webserver

people i have to create a second site in the same webserver that i already have my first site. i,m not sure on how i can do this, i would not like to have to change all the url that i have already created. i was thinking on installing a second joomla inside the folder where is the first one. the url will be www.myweb1.com/joomla2, that is something that i would not like is there a way by my dns that i can change that www.myweb1.com/joomla2, to www.joomla2.com
I just want to create a new joomla site in the same webserver that i already have one joomla site. I,m using apache2 with opensuse. the first site already have a vhost to manage https rewrite conditions.
Any recomendation.
You can use the proxy functionality of Apache HTTPD.
Such configuration might look like:
<VirtualHost *>
ServerName www.joomla2.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://www.myweb1.com/joomla2
ProxyPassReverse / http://www.myweb1.com/joomla2
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>

Plone with Apache Proxy

I have a plone zinstance set up through Apache Proxy on OS X Server 10.5. The server is set up with a single vhost on port 80, with Proxy & Proxypass directives to the Plone zinstance:
ProxyPass / http://localhost:8080/VirtualHostBase/http/server:80/Plone/VirtualHostRoot/
ProxyPassReverse / http://localhost:8080/VirtualHostBase/http/server:80/Plone/VirtualHostRoot/
However, I have some static HTML and PHP content that I want to display in an iframe via the plone site. I'm thinking I'll need to set up another vhost on a different port, then just specify the port # inline?
Set up a static URL that will not be proxied but served from Apache directly, like this:
ProxyPass /static !
ProxyPass / http://localhost:8080/VirtualHostBase/http/server:80/Plone/VirtualHostRoot/
ProxyPassReverse / http://localhost:8080/VirtualHostBase/http/server:80/Plone/VirtualHostRoot/
Then configure /static to contain your static content.
I'd recommend rolling your configuration into a virtual host block. You can deliver static content directly form apache by rewriting a specific path. Here's an example
<VirtualHost *:80>
ServerName yoursite.com
Alias /static /var/www/some/path/
<Directory "/var/www/some/path">
Options Includes FollowSymLinks
AllowOverride All
</Directory>
# Zope rewrite.
RewriteEngine On
RewriteRule /static - [L]
RewriteRule ^/(.*) http://127.0.0.1:8080/VirtualHostBase/http/%{SERVER_NAME}:80/Plone/VirtualHostRoot/$1 [L,P]
</VirtualHost>
Sorry, not enough information but I'll offer a couple of comments that might help point you in the right direction.
First, ProxyPassReverse is unnecessary as Plone already takes care of fixing up any self-referential urls. That is the point of the crazy url after all.
Another poster already showed how to configure ProxyPass to selectively bypass the proxy to Plone and serve from Apache directly.
Regarding the "additional vhost on port 8888". It's not clear what you mean by this. What is the extra vhost serving? If it's where your static html and php content is supposed to come from then restricting to localhost only means you're going to have to also configure an internal proxy to reach it. You can do that with Rewrite rules but that seems like an overly-complicated way to go in this usecase. Why is this vhost available to localhost only? For that matter, why are using a separate vhost... you can do this all (Plone, static files, and PHP) in just one vhost with the appropriate ProxyPass lines (or Rewrite lines if you need more flexibility).

Resources