Prioritize folders in URL rewrite for IIS7 - iis-7

We are currently using CommunityServer for our website.
A recent change called for the creation of a shorter URL to access a user's profile page. So if our site is www.example.com, we want the user profile page to be accessible via www.example.com/username.
To make sure that existing folders/paths are prioritized, I placed the rewriting rule at the very end in SiteUrls.config:
<Override xpath = "/SiteUrls/locations/location[#path='/']" mode="add" where="end">
<url name="userslug" path="" pattern="/([a-zA-Z0-9\-]+$)" physicalPath="/user/" vanity="{2}?slug=$1" page="userprofile.aspx" />
</Override>
This worked quite well while testing in my local environment via VS2010 Debug. Accessing www.example.com/folder gets redirected to www.example.com/folder/ and the default page is shown properly.
However, when we deployed the change to live, accessing www.example.com/folder returns a user not found error, which just means that looking for an existing folder was not prioritized somehow.
I'm not sure what relevant information to give from our live server, but is there anything I should take a look at to make the URL access work like how it is in VS2010 Debug?

Apparently, all you got to do is to create a URL Rewrite rule to add trailing slashes to directories via IIS.

Related

index.php is bypassed in wordpress local install

hello I have a local wordpress installation, which is a copy of my hosted website.
i'm going to try to make it simple :
If i type "http://mylocalwebsite/index.php", it works and shows me my local copy
If i type "http://mylocalwebsite", index.php is still used, but i'm ending in my hosted web page (www.myrealsite.com)
If i type "http://mylocalwebsite" again, it doesn't use index.php, and directly opens my hosted website.
All hosts files are correct, none of them is leading to my hosted website.
I've done a search for "www.myrealwebsite.com" in the directories of the local copy : no result.
I just don't understand why. Any ideas ?
Thx
This is a cached redirect from the browser you are using (since the hostname you are using is not FQDN, the browser tries to correct that, or has previously seen a (301) redirect to the real webpage like from non-www hostname, to a www.hostname and uses that to assume what is correct).
If you try the same with CLI curl request, I would imagine the result will be as you expect.

Load Drupal Site on Any URL

I'm setting up access to a Drupal 7 site. The site sits alone on a box that answers to a number of domains and that number is likely to grow. What I'd like to do is to tell Drupal to load the site regardless of which actual domain brought us to the box (the rest of the URL will always be the same, of course). Currently most of those domains send me to the install page.
The problem is the lack of a directory (symlink) in the sites/ directory.
I can probably rewrite requests coming through alternate domains in Nginx, but I'm wondering whether there's an application level answer. As it stands right now, accessing the box/site by any domain other than the canonical domain sends me to the install page.
Is there anything I can do?
It looks to me that you didn't configure your Drupal site as the "default" one.
The file "sites/default/settings.php" is loaded if no better (more specific to the current request) settings file can be found in the sites/folder... This is in fact a "wildcard" config, so the best solution would be to move the site files to the default folder. See the multi-site documentation for more details.
If you can't do that, then you can use sites.php for the rewriting, but you will need to update it to add any new URL you want to match. There's a little shortcut though: you can add a bunch of rewrites such as
$sites['com'] = 'default';
$sites['net'] = 'default';
$sites['org'] = 'default';
...
which will act as catch-all rewrites for sites ending in .com, .net, .org and so on, saving you a lot of (but not all) the manual rewrites.
Altering the conf_path() function should really be your last solution, since it will make updating Drupal a slower process (and if you forget to re-apply the changes after an update, your setup won't work any more).

The Web server is configured to not list the contents of this directory. asp.net vs 2012 error?

Got following Error:
HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
this is how I linked css file.
<link rel="stylesheet" type="text/css" href="~/styles/StyleSheet.css" />
i am using master page for first time. i did added master page in iss server.
i enabled the directory setting in my iss 8.0
Have you tried setting the following within your web.config file :
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
The Web server is configured to not list the contents of this directory
The keyword in the error is list.
That sounds more like you do not have a default document set up. If you don't have one, nor don't request a specific document (e.g. http://www.foobar.com/ or http://www.foobar.com/foo.html respectively) IIS will not "know" what to "serve" to the browser nor will it, nor should you expect it to, list the contents of that directory (instead).
See: Microsoft Support: Error 403.14
A Short Story Of A Lost Controller, And A Happy Ending
Let's say you have a controller called Data, in the project file /Controllers/DataController.cs. You can access it just fine via http://yoursite.com/data, which is handled by the DataController.Index action method.
Then, somehow, it breaks, and you start getting "The Web server is configured to not list the contents of this directory" when you visit this URL. Strangely, visiting /data/index still works! You try all the suggestions found online to make this work but can't seem to do it. What could it be?
Perhaps you ought to think about what the error means. It says that when you visit /data, it finds a directory there, but you aren't allowed to see the files in it. Setting aside the fact that your routing doesn't seem to work and it should, could there actually be a directory there?
Yes, there could! In your web project, you cleverly added folder /Data! This is a physical folder that takes precedence in the server's static routing rules (since you didn't rewrite those so physical files would be looked at after managed virtual paths).
The solution is thus to rename the folder, or rename the controller, one or the other. This will fix your problem quite speedily and you may then proceed on your merry way coding long into the night to the enveloping strains of techno Spanish mandolin trance music, with your trusty cat snoozing on your foot and the cold beverage of your choice beading up on the desk next to you!
The Ramesh Rajendran's answer must working, but you can use look at what is the modules your web application use and add in system.webServer tag on webconfig file to they use it. I had this error also in a test web application when I put it on Server IIS.
It's very strange not list the contents with the option enabled on IIS Web Server.
When you press Ctrl+F5, then IIS don't understand what to serve as you don't have any Default aspx file in your site , i recommend you to add a aspx file by going to Add>NewItem>Webform>
Note: remember to check the box at bottom right , "select from master page"
after selecting , save all the pages and just open your default.aspx file and you will surely see the reflected design as you did in master page.
Master pages are not aspx file but serve as a template for other webpages , so you cant just open master page.
Don't start the debugger while you are on the master page. EdSF pretty much summed up why.
In addition, you also may need to set a default start page(right click, set as start page).
You should define a default document value in web config and disable directory browsing.
<system.webServer>
<defaultDocument>
<files>
<add value="insertion.aspx" />
</files>
</defaultDocument>
<directoryBrowse enabled="false" />

URL Rewriting in IIS7 annoyingly adds folder name to url

I'm having trouble with my URL Rewriting; IIS keeps adding the folder name to the url.
E.g. my.site.com/Login/ gets re- written to my.site.com/MY/Login
The frustrating thing is that the my.site.com/Login/works but whenever a link is clicked it adds the /MY/ to the url.
Does anyone know how to resolve this?
Existing re-write rule: (http(s)?:\/\/)?my.site.com
Rule I'm playing with (not finished) to try and detect the /MY/ and redirect to the 'proper' url
(http(s)?://)?(www.)?my.site.com/MY/
Thanks!

Web.Routing for the site root or homepage

I am doing some work with Web.Routing, using it to have friendly urls and nice Rest like interfaces to a site that is essentially rendered by a single IHttpHandler. There are no webforms, the handler generates all the html/json and writes it as part of process request.
This works well for things like /Sites/Accounting for example, but I can't get it to work for the site root, i.e. '/'.
I have tried registering a route with an empty string, with 'default.aspx' (which is the empty aspx file I keep in my root folder to play nice with cassini and iis). I set RouteExistingFiles to false explicitly, but whatever I do when hitting the root url it still opens default.axpx, which has no code it inherits from, and contains a simple h1 tag to show that I've hit it.
I don't want to change the default file to redirect to a desired route, I just want the equivalent of a 'default' route that is applied when no other routes are found, similar to MVC.
For reference, the previous version of the site didn't use Web.Routing, but had a handler referenced in the web.config that was perfectly capable of intercepting requests for the root or default.aspx.
Specs: ASP.NET 3.5sp1, C#, no webforms, MVC or openrasta. Plain old IHttpHandlers.
Fixed my own problem: the issue is the integrated web server, Cassini or some such. Seems that it doesnt play nice with routing, and will by default simply return the default.aspx file or, if it is missing, show a directory listing.
Using IIS with a virtual directory works fine, but is annoying (frustrates code sharers because they need to set up new virtual directories when they open my app, and pollutes my own IIS instance. Bah. Probably what I'll do for the moment however, or setup a new application manually so I can use the domain host only path like what will exist in live.
An alternative is to use the updated version of cassini, seen here, which works if the default.aspx file is missing, but I have not worked out how to integrate it with visual studio yet. Any help would be appreciated, but its not a big priority given I have workarounds.
I realise that this is a really old post, but I just ran into the same problem using VS2012, so I'm posting this here just in case.
I solved the problem by installing IIS Express and setting the project to use IIS Express in Visual Studio. Solved the problem.

Resources