How to configure a subdomain to open a subpage on the main domain with nginx? - url

So I have a domain example.com and a subdomain sub.example.com.
I would like to configure my Nginx virtual host to open the root site when a user uses the domain example.com but when a user uses sub.example.com the server should serve example.com/sub. The main problem I'm having is the URL changing. I do not want to simply redirect, instead, the URL should stay the same.
So basically you can open the same page by visiting example.com/sub or sub.example.com but the URL should always be sub.example.com.

In your nginx configuration file for sub.example.com, under location /,
You can proxy-pass to the page you want to show. In this case example.com/sub.
But if you have more links on example.com/sub page, your routing would need some tweaks. Else, it should work fine.

Related

How to forward non-www URLs to www URLs

I've had an issue with Google Adsense not being able to access their config file (ads.txt) on my Rails site. I have put it in what I think is the correct folder (App -> Public).
In summary, this is the situation for which URLs work vs not:
[webURL].co.uk/ads.txt (works)
https://www.[webURL].co.uk/ads.txt (works)
http://www.[webURL].co.uk/ads.txt (works)
https://[webURL].co.uk/ads.txt (doesn't work - hangs)
http://[webURL].co.uk/ads.txt (doesn't work - error - HTTP Status: 404 (not found)
So my guess is that Google is trying to reach ads.txt via a URL without a www (the two bottom of the list above).
A couple of other points:
My Rails app is hosted on Heroku and I have a GoDaddy domain
On Godaddy, I have domain forwarding already setup, and so [mysite].com gets forwarded to www.[mysite].com.
So my question - how do I get URLs which don't have 'www' in them, to redirect to the equivalent URL with 'www'?
Any ideas?
Thanks in advance!
I resolved this by setting up Cloudflare and configuring some forwarding rules.

Remove index.html from url in Weebly without .htaccess file

I want to remove "index.html" from the homepage URL of Weebly site without .htaccess file, please help me to resolve this problem.
Weebly does not currently provide the option to redirect /index.html to the root domain URL or give you the access needed to properly make those changes, however, links to your home page (at least on your website) should be going to the domain-root.com and not /index.html so you should be ok there.
Keep in mind that index.html is a file, that exists as the home page for the folder your website pages live in, and you can't remove it from it's existence(at least on Weebly).
So, the thing to do would be to submit it to Weebly as a Feature Request and request that they make the necessary changes on their end, for the sake of ALL Weebly users! ;)
https://community.weebly.com/t5/Vote-on-Features/idb-p/IdeaExchange

Zend Framework 2 index.php in root folder

I am bulding a website with zend framework 2 and a URL typically looks like this:
domain.com/public/routename/action/params
In the skeleton application i don't have index.php by default, so i created one what basically includes the index.php from the public folder.(This is absolutely not the correct solution). What works but slows down the whole website, also the redirect plugin still redirects to domain.com/public/routename/action/params insetad of domain.com/routename/action/params
How could i skip the "public" in the URLs and get the redirect plugin to work?
Either you can do this from webserver from where you can point the public folder index.php so either point the domain to zf2 you should point to zf2/public/index.php
Another way is you can use htaccess and remove the public url
You should configure your web server so that it serves from public instead of the ZF2 root folder.
Not sure if you use IIS or apache or NGiNX, so without those details it is hard to say what you need to do exactly. But it should be easy to find a 'how to' for your particular web server.
It comes down to configuring what folder should be server for that particular virtual host.
Google can help you

IIS Default Site

I have an IIS configuration such that [mywebapp] is an asp.net mvc web app that exists under "Default Web Site" of myserver.com.
How do I configure my IIS so that a request to www.myserver.com actually displays the home page of [mywebapp], without changing the url to www.myserver.com/mywebapp. Currently the url change is what happens as I am using HttpRedirect on Default Web Site, but this is not what I want.
Assuming that you have a DNS record set that maps your server IP address to the domain name, you will need to set up a new site, rather than a virtual directory underneath Default website. When you create the site, enter your domain name in the Host name field.
You can test this configuration locally first by setting the site up in IIS and then adding an entry in your hosts file (C:\Windows\System32\drivers\etc\hosts) that maps the domain name to your localhost IP address 127.0.0.1 - just remember to remove that once you're happy with the setup or you won't actually be hitting the live IP address.

Hiding URL when redirecting

Is it possible that I can hide the URL where I redirect in CPANEL.
For example :
My Website : www.abc.com
My other website : www.xyz.com
When redirecting from abc.com to xyz.com I want that the adresse stay abc.com !
How can I make it in CPANEL. ??
The only thing you can do without using IFRAME is that, you will need to update your vhost config file for this for apache:
Following blog post should give you better idea about that:
http://blogs.digitss.com/apache/mod_proxy-mod_vhost_alias-to-host-multiple-domains-on-web-server-and-running-apache-iis-together/
Scroll down to title: How to host multiple domains/sub-domains on a web-server using Apache Virtual-Hosting (mod_vhost_alias)?
But I doubt how would you get to apache config if you are using shared hosting services?
Though I am not sure if you have your own server you can do it easily else talk to hosting support.

Resources