How do i configure IIS so that a websites internal links beginning with a slash "/" reference the root of the website not the root of the webserver - url

I'm trying to implement URL redirecting in different websites hosted on my W10 IIS10 development PC and from searching SO i believe that internal links for JS and CSS files need to start with a forward slash e.g. ....src='/css/styles.css'
How do i configure IIS so that internal links beginning with a forward slash reference the root of the website rather than the root of the webserver
I've tried creating an application pool and configuring and attaching it to a site
Internal links in website starting with a forward slash still seem to be looking at the root directory of IIS rather than the root directory of the website
Website within IIS

When using resources in a web project, you must specify a path for the resource. You can set the src attribute with a site root relative path, resolved against the site root. Site root-relative paths are useful if you keep resources used throughout your site, such as images or client-side script files, in folders located under the site root.
This article may help you: https://learn.microsoft.com/en-us/previous-versions/ms178116(v=vs.140)?redirectedfrom=MSDN

Related

IIS Sub-application root

I have an existing Web Application hosted in IIS which an ASP.NET MVC application. Now I want to add a sub application,But when I deploy, some relative paths like "~/" or "/" will be imported back to my parent application.
Example:
The URL of the parent application is https://www.example.com/
Then my sub application is https://www.example.com/subApp/
When I try to click on the "subApp/test" page, it should be directed to https://www.example.com/subApp/test, but he still leads back to https://www.example.com/test.
How can I solve it?
Can it be modified through Web.Config instead of going to each page one by one
check your URL rewriting module. if it is there?

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

URL Routes In IIS7 MVC 5 (Single Paged Application)

After publishing a MVC5 web application of mine to my IIS server (Individual User Accounts), it would seem that the URL is accessed incorrectly.
During debug, it would be e.g http://localhost:1234/api/Account/UserInfo?=XXXXX
The debug works just fine. The only issue kicks in after I've published it via my IIS7 server.
After publishing and using Google Chrome's console, it would appear that the page is requesting for a resource at mydomainname.com/api/Account/UserInfo?=XXXX instead of mydomainname.com/WEBAPPLICATIONNAME/api/Account/UserInfo?=XXXX.
My best guess is to modify the URLs in /Scripts/app/app.datamodel.js but it would just cause more parsing problems.
I've searched around and can't seem to find any related problems. I hope someone here will be able to lend a hand.
Look like you are using relative path like "/api/Account/UserInfo". Instead i'll recommend you to use #Url.Content("/api/Account/UserInfo"). This will solve your problem
Explanation
In local system when we run application in WebDev server it never have sub folder (like WEBAPPLICATIONNAME) therefore you relative path work correctly. but when you host your application in IIS under Default website in another new website /Virtual folder (like 'WEBAPPLICATIONNAME') then "/api/Account/UserInfo" fall back to Default Website because for '/' in starting. #Url.Content or #Url.Action make sure to add virtual directory name, hence changing your path to "/WEBAPPLICATIONNAME/api/Account/UserInfo" in IIS.

Running MVC application on IIS without domain

My application contains lots of links to the root ("/login/dologin"). When I'm running the application under a domain, there's no problem.
Right now I'm moving to a new server, and I can't test my application. My application sits in "localhost/md", I need the link to go to "localhost/md/login/dologin". Instead, it goes to "localhost/login/dologin", and, ofcourse, the resource cannot be found.
What do I need to configure on my IIS to make this works without domain?
Thanks.
It's just a guess, since you haven't posted any of your configuration.
In your authentication element in the web.config, do you have the route to the login page specified as /login/dologin? could you try ~/login/dologin
The second option, should give you a relative path from the home of the virtual directory application, rather than going to the root of the 'site'
For referencing files (e.g. javascript & css) you could do #Url.Content("~/path/to/file.js")
EDIT: Based on additional comments
in Layout.cshtml...
var SITE_ROOT = '#Url.Content("~/")'
then in your JS file use SITE_ROOT as a prefix in your routes
var url = SITE_ROOT + "Home/Index";

Joomla Site URL

I have a website on a 1and1 server. I have 2 domains on the package; the default url somenumbers.websitehome.co.uk and my actual URL.
The problem is, Joomla quotes the somoenumbers.websitehome.co.uk in system e-mails instead of my actual URL. They both point to the same directory I just don't want to give a stupid URL to my users.
I think I have narrowed it down to the $siteUrl variable but I'm not sure how to go from here.
Thanks
James
At first I thought this sounded largely like a DNS issue - but then you said you only have 1 Joomla installation and both domains point to that directory.
If they're both pointing to the same directory, then both domains will display the same Joomla installation. That is, unless you're checking to see where they are coming from and having the content display dynamically based upon how they got to your site - but from your comments I doubt you're doing that. How your domains are behaving is the expected response if you're pointing them both to the same directory.
If you want 2 sites on the same hosting? Setup 2 databases (or apply different prefix for each site and use 1 database) and set up each website in it's own directory.
Adjust the DNS of each domain name (and subdomain name) to point the appropriate directory.
From there, use the .htaccess file and SEF URL's to get rid of any indicator of the directory so that it displays the same as if the site was in the root directory.
That is the best way to accomplish what you're after - because from the sounds of it Joomla is doing exactly as it should, displaying correctly what is in the directory since both domain names point to the same directory.
$siteUrl should be left blank.

Resources