How to prefix all requests with ~username? - linux

I'm testing moving my site to a new Linux server using cPanel which requires you to put in your IP and username (e.g. http://123.xxx.xxx.xxx/~username/). The problem is, all my image/JS/CSS links use paths like /css/style.css or /images/picture.jpg so none of the styles, scripts or images show up properly.
How do I set up a RewriteRule to prefix ~username to all requests?

Before moving site, if it was working with only domain name and with redirection then now it should also work with server IP and username, Make sure the permissions and ownership of /css/style.css or /images/picture.jpg are correct.
Also check it once adding exact path manually like 'http://123.xxx.xxx.xxx/~username/css/style.css'.

I was able to get around the issue by setting the domain to a dedicated IP instead of shared, so I could access the site using 123.xxx.xxx.xxx instead of 123.xxx.xxx.xxx/~username.

Related

Reverse proxy passthrough for multiple websites

I'm building a website where there will be user generated content, for example under the url website.com. Each user might have a page (of their own content) somewhere like website.com/user/jack, website.com/user/lucy, etc. This number of users (as well as their names) are dynamic and can be added any time. I already have website.com working and deployed.
I'd like to be able for users who have their own domain name, e.g. jacks-website.com, to be able to use that domain name but effectively have it act and behave as website.com/user/jack. By this, I mean the following:
jacks-website.com is has the same DNS records as website.com.
jacks-website.com serves exactly the same content as website.com/user/jack. This also goes for any/all (nested) subpaths, i.e. jacks-website.com/custom-path -> website.com/user/jack/custom-path.
A user browsing jacks-website.com will have NOT be directed to website.com/user/jack. To them it should feel like browsing jacks-website.com directly.
I've tried playing around with Node's http-proxy package, where I would check what req.headers.host is then map it to a corresponding /user/jack path. However, I still couldn't get it to work as it would cause jacks-website.com to redirect to jacks-website.com/user/jack.
Also note that I'm fully using SSG/SSR on my website.com app, so no need to worry about client-site routing or anything.
Thanks a lot.

Rename directory name using .htacess

It's hard to explain, I would like to do something like below but I don't know how.
I currently own two different domain names and have one website.
Can I have two domains pointing to the same website but the URL only shows whatever domain is entered in the first place?
For example, when I type in 'domain123.com', it takes me to my website (IP address 111.222.333) with the URL shown as 'domain123.com'. Then when I type in 'domainABC.com', it also takes me to the same website (IP address 111.222.333), but the URL needs to show 'domainABC.com' instead of 'domain123.com'.
I guess I will need to redirect one of the two domains to the website, but how can I stop the URL changes the domain name?
I am not sure if I can just modify .htaccess to achieve above or if I also need to change the DNS, etc. to make this work.
Please help and many thanks
It depends on your setup and your server permissions.
A nice way will be to change the docroot in the apache or nginx config.
If you don't have permissions to edit these configs, you can create a symbolic links so that the public folder of domain2 points to the public folder of domain1

DNS redirect of a url to another url

We are currently looking at identifying the best approach to carry out a redirection of a url folder to another url folder o a separate domain. We have tried a few options but have been unable to make this work. Any other redirection options such as apache, html etc are not possible. This url is only accessed through the browser by an application to download some files. This application cannot be changed but needs to download these files from another location.
Hence, we need to redirect the following:
https://sub1.domain1.com/xyz
to
https://sub2.domain2.com/abc/xyz
Any ideas how we can achieve this?
Note: we have full control of DNS of the domain1 and there are no plans to use this domain.
You can't do that with DNS alone. The DNS never sees the "path" part of the URL. You need a webserver aware of the situation who can provide a 302 redirect.

Point IIS8 virtual directory to a different server IP Address?

Here is my issue (keep in mind I am used to linux not windows servers): I have a website domain.com (.asp site) that is hosted on an IIS8 server and then a folder domain.com/folder that needs to point to a different servers IP address that holds a different site (linux server running Magento).
I know personally that a subdomain should have been created and DNS pointed to it correctly like folder.domain.com but I have inherited this issue and am trying to see if a solution is even possible.
Thank you all in advance.
I dont have previlage to comment in your question.! So I commenting here.!
Have you ever crossed symlinks? I hope you need the following link. The question is not clear though.
check this out.
Symlink created with mklink not working with IIS7.5 -- Windows 7
Responding as another team member on this project--
A 301 redirect is not a viable option by nature of Magento's URL request mechanism (if the request didn't originate from the URI set in the config, then redirect to it). We either end up with infinite loops, or IIS rewriting headers to trick Magento in to thinking the request URI is correct and performing a 301 redirect on every resource on the page (and the page itself, of course). This breaks miserably on POST requests.
We must be serving fully-qualified URLs from domain.com/folder/foo-bar.baz.
Switching to Linux is not possible. Please don't suggest what we already want.
Thanks, SO.

IIS: Can I create a host header for an intranet site?

This is a fairly simple question (in my opinion) but for some reason despite my Googling I cannot find a straight answer to it.
Currently I have an application running under my Default Web Site located at http://localhost/myApp. Ideally, I'd like to create a new site in IIS with a binding to 127.0.0.1:80 and a host header of http://myApp so that I can test my url rewriting rules properly (since my app will ultimately be hosted at http://www.myApp.com, not http://www.somedomain.com/myApp).
So, my question is this: will the above work? I haven't had a chance to try it yet.
If the above will not work, what are the steps to be able to access my site at http://myApp on my local network?
It should work provided you fool the OS into resolving www.myapp.com to 127.0.0.1. To do so, edit your hosts file in %systemroot%\system32\drivers\etc to contain the following:
127.0.0.1 myapp.com
I believe you could do just myapp(without the .com) as well, but that gets a bit trickier because how that is resolved depends on your node type. (hybrid, etc) To be safe, add
127.0.0.1 myapp
to BOTH the hosts and LMHosts files in the same directory. By default the lmhosts is non-existent and there is a lmhosts.sam there. You'll have to rename that to just lmhosts or create a new one.
Then create the binding as per usual in IIS7/7.5 (I assume it's 7... Site->Actions->Bindings->Add or Edit->Populate hostname accordingly).. IIS6 will work too but it's alot harder to get https working should you need it.

Resources