URL Rewriting in IIS7 annoyingly adds folder name to url - asp.net

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!

Related

Add New Window Attribute to CQ Page Redirects

I am trying to add a *target='_blank'* option to all CQ pages that only redirect to either an outside URL or media file (i.e. PDF). I am looking in components/parsys/parsys.php which I assume would have some block of code for a server-/client-side redirect but to no avail.
I realize that if the redirect is in fact server-side then I cannot open it in a new window. But until I know either way, can someone help point out where the actual redirect script code is?
If you are using the out of box redirect mechanism (where you fill out the redirect target on the Page Properties dialog), the default redirect logic can be found under:
/libs/foundation/components/page/page.jsp (CQ 5.4)
The code is doing response.sendRedirect so you may not be able to force redirects to open in new windows from there.

Prioritize folders in URL rewrite for IIS7

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.

Plone, behaviour of URLs

The situation is the following: I created a site with Plone, developed, used, but behind a test URL. Now it has to be published, but the test URL is not appropriate and I don't want to move the site. I think, if I use a redirect, it won't be appear in the URL-bar, only in the case of site start page. Am I wrong? (The test URL should not be used, because it will be a "semi-official" site.) What do you suggest to do?
As far as I can see Plone uses absolute URLs everywhere. I can add relative URLs, but if I create a new page, a new event, etc., then they have absolute URLs on other automatically generated inner pages. Is there any way to convert these URLs to relative paths? Is there any setting possibilty where only a checkbox changes this default setting?
Plone does not store your URLs in the database. It uses the inbound host header (and any virtual hosting configuration set up with rewrite rules in Apache or Nginx) to calculate the correct absolute URL when rendering the page.
In other words - as soon as you actually point the relevant domain name to the server with your Plone instance, it'll just work.
P.S.
You should put a bit more effort into asking your question. This is just a copy and paste of a half-finished email chain where you tried to get the answer from me in private. It's not very easy to understand what you're asking.
I think what you are looking for is url rewriting to handle virtual hosting. ie to get your site to appear as if it's the root url of a domain.
This is normally done via the webserver that normally sits in front of plone. For apache, here is a howto
http://plone.org/documentation/kb/plone-apache/virtualhost
for other servers
http://plone.org/documentation/manual/plone-community-developer-documentation/hosting
You can also achieve this directly in zope (via ZMI) using something called the Virtual Host
Monster. see http://docs.zope.org/zope2/zope2book/VirtualHosting.html
PS. I don't think your question is badly worded. Plone does serve pages with a "base" tag and what appears to be absolute urls. They aren't baked into the database but it's also not obvious that the solution to getting the url you want is the VHM url syntax and a proxying frontend webserver. There is a reason why it doesn't use relative urls... which I can't remember it was so long ago.

asp.net changing website root

I am URL routing myself.
Main project only contain the URL routing code.
Different websites are placed on approot.
e.g: I have deployed VS2010 test-default-website at approot/webTest/.
I am trying to opening http://webTest/Account/Login.aspx from browser.
For that URL request, I am serving page using PageParser.GetCompiledPageInstance(), as follows:
In URL route request handler,
return PageParser.GetCompiledPageInstance("webTest/Account/Login.aspx", HttpContext.Current.Server.MapPath("webTest/Account/Login.aspx"),
HttpContext.Current);
I am getting following exception:
The file '/Account/webTest/Account/Login.aspx' does not exist.
PageParser.GetCompiledPageInstance is automatically appending '/Account' before the actual address, thus unable to find it.
How can I make it not to append '/Account' ?
Thank you.
Best Regards.
"webTest/Account/Login.aspx" is a relative path, add a slash to beginning to make it absolute: "/webTest/Account/Login.aspx"

Possible bug/issue in ASP.NET 3.5 related to Request.RawUrl property

I posted a query for 301-redirect using ASP.NET 3.5 here:
Redirecting default.aspx to root virtual directory
Based on the replies I got there, I realized there might be a bug in ASP.NET's Request.RawUrl method which is unable to return the actual raw url (without /default.aspx) when being used in a sub-directory, i.e. the /default.aspx page is inside a subdirectory.
Can someone please shed some light on this possible bug?
Thanks,
Asif
i found a good explanation here
http://codeasp.net/blogs/vivek_iit/microsoft-net/873/301-redirect-from-default-aspx-to-site-root
Thanks
If you suspect this is a bug, then the place to go is Microsoft Connect, where you can report and discuss the bug directly with Microsoft.
Edit: I was able to reproduce the look per your comments.
I was unable to reproduce the infinite loop, however. I injected code into the Global.asax Application_BeginRequest handler of a web application and got the expected behavior of a single redirect.
There are other, and IMO much better, options for handling global redirect rules. On IIS7, I use the URL Rewrite module to configure rewrite rules in IIS. You can read more about it and download it here: http://www.iis.net/download/urlrewrite. The appeal of a solution such as this is that you can customize and update your rewrite rules without recompiling the application.
Edit: I was able to retrieve the raw URL without the default.aspx (after the redirect) by using instead:
Request.ServerVariables["CACHE_URL"]
It's worth a shot.
Have you looked at the IIS settings for your virtual directory? If there is a default document set to default.aspx then this will explain the infinite loop that you are experiencing. You are telling the website to redirect to the virtual directory without the "default.aspx" and IIS is detecting this on the next request and putting it back in ad infinitum.
Right click your virtual directory, select Properties and then the Documents tab. If default.aspx is in the list then that is what you will get. The Url of the request will be passed to the ASP.NET worker process as /folder/default.aspx rather than /folder/
This is not a bug. If IIS didn't do this, you would get a page not found error.
Sounds to me like you need to investigate URL rewriting: http://msdn.microsoft.com/en-us/library/ms972974.aspx

Resources