Regexing it up with IIS re-write module - asp.net

I am developing a profile-based web application where each user is assigned there own url through their username & iis rewrite mod's magic. A typical user's profile url would be http://www.mymark.com/mike
Each user is also created a blog in a multi-user wordpress installation. The wordpress url would look like this: http://www.mymark.com/blog/mike
I am trying to use the rewrite module to create more canonical urls for the user (http://www.mymark.com/mike/blog), and have tried several regex variations that I have created through RegExr(a regex generation tool) and come up with this as the pattern to match (www.|)mymark.com/([^/]+)/blog but haven't had any success so far. What am I doing wrong here?
Here is a screen shot of my re-write rule:

The entire host name (mymark.com) is not part of the URL, so you should not enter that as part of the Pattern. To make sure you easily figure it out, make sure to use Failed Request Tracing to extract the exact pattern that you should enter there:
http://learn.iis.net/page.aspx/467/using-failed-request-tracing-to-trace-rewrite-rules/
but its probably going to be something like:
(^/])*/blog

Related

How to create an a virtual hostname or a simple url for appmaker

The URL for app-maker is always pretty complicated and is not human readable...
Is there a way to configure a host name or simplify the URL, in order to have the users being able to remember it?
for example:
myapp.mydomain.com
or at least:
scripts.google.com/myapp_prod or similar?
Until now I wasn't able to find out a way to have a fixed URL for the prod deployment for example.
If you want that for accessing purposes only and if you have some kind of hosting, a permanent redirect will do the trick. Alternatively, you can use some javascript to redirect to the app url whenever the home page is loaded.
window.open(appurl, "_top");
But other than that, the comment provided by Markus Malessa is the most correct one.

URL issue in NopCommerce dot(.) is not accept in URL

I'm working on NopCommerce Project and
I want a URL like : www.youstore.com/category.cfd
but in SEO I entered the category.cfd but it does not accept the dot(.) in URL it will automatically remove dot(.) while i'm saving the SEO name.
Please, help me out for that
Dots in this kind of urls are not supported by nopcommerce, all the urls of products and categories are cleaned to keep seo friendly urls.
You can tweak nopcommerce to allow dots (changing the source code or changing the UrlRecord table values) but when you add a dot to the url, the .Net extensionless handler used to process mvc request will not catch that request anymore, that means that you will recieve a 404 error because the web server will be searching for a phisycal file.
If the dot is mandatory by your requirements you can use the url rewrite module at iis level and rewrite all the urls (for example all the urls finished with .cfd) removing the dot, so internally you will have www.youstore.com/categorycfd or www.youstore.com/category, this can be tricky because you need to keep dots for file paths as images.

Single Page ASP application and Routing

I thought this would be very simple but it's proved difficult to find the information I'm looking for online... I have a single page website using ASP and I want to use query strings but I don't want to have to put Default.asp in the URL. So at the moment the URL would be something like:
http://localhost/default.asp?id=4
But I'd like something like:
http://localhost/watch?id=4
I'm not using Visual Studio so was hoping to be able to do this with a simple text editor. I'm not that familiar with ASP either so this I'm very much a newbie with these concepts.
You have 2 options.
1: Use URLRewrite extension from Microsoft that can be found here
You can set-up an inbound rule for the pattern: watch using wildcards, and add conditions that disable the rule when a file or directory actually exists. (URL Rewrite sets this by default), then create your action to point to default.asp and check the Append query string box. Then it will route all /watch url's to your default.asp page and will allow your script to read all querystrings as it does normally.
2: Use a custom 404 error page:
Point your error 404 page to the default.asp page in IIS, but you will need to use Request.ServerVariables("Querystring") to parse out the actual URL requested, since the 404 error page is not able to get your querystring by using Request.Querystring as you will be able to do in option 1. You will have to create your own url reading system, since the data returned as the querystring would be something like ?404;http://www.domain.com/watch?id=12312, instead of ?id=12312 like it would in option 1.
Personally I would use the 1st option, even though it requires to install the extension, it's more flexible and doesn't fill up the logs with 2 seperate requests like option 2 does, and its just more transparent to your script rather than creating your own url reading system as you would have to using option 2.

Correct redirect URI for Google API and OAuth 2.0

I am making an application with the Google Maps API. I want to be able to have one person on a computer, watch what another person has edited to a map. I am thinking of passing information of the map to a Google Fusion Table. The other person will be able to see everything as a layer. I would like for the program to just run from the user's browser and not build a website for it.
To edit the fusion tables, I need to gain access/tokens. I am currently trying to use these there JavaScript to accomplish this. ScriptSample.html, oauthWindow.html, and gwt-oauth2.js. This is the working example.
When I run them, I get am error that says the redirect URI is incorrect. It says the file I use to redirect does not have authority. My first obvious question is:
How do I give that file authority to redirect?
In my API console, I have it set up as a client-side web application. Should I change it to an installed application?
Currently I have the following settings:
my JavaScript origin is: https://localhost
redirect URI: https://localhost/oauthWindow.html
Thanks
There's no problem with using a localhost url for Dev work - obviously it needs to be changed when it comes to production.
You need to go here:
https://developers.google.com/accounts/docs/OAuth2
and then follow the link for the API Console - link's in the Basic Steps section. When you've filled out the new application form you'll be asked to provide a redirect Url. Put in the page you want to go to once access has been granted.
When forming the Google oAuth Url - you need to include the redirect url - it has to be an exact match or you'll have problems. It also needs to be UrlEncoded.

URL aliases: rewrite, routing, not sure

ASP.net 4.0 / IIS7.
I want to "alias" a single web form to appear as various extensionless urls. Given a form in my web root called "mySite.com/ColorWebForm456.aspx":
I want it served as multiple names, e.g., mySite.com/Color, mySite.com/Colour, mySite.com/Colors, mySite.com/Coler, etc., without creating folders and duplicate forms with those names.
I never want mySite.com/ColorWebForm456.aspx displayed in the browser, it needs to display as mySite.com/Color, even if the user somehow acquires it and types in that exact ~.aspx address.
The variations will account for several alternate or mis-spellings users might attempt - I don't want them "corrected", however. So, if a user types in mySite.com/Colour, the url is NOT rewritten to mySite.com/Color, but the same page is served via ColorWebForm456.aspx as the requested "mySite.com/Colour".
I've seen so many articles on this that I'm not even sure where this would be best handled: in Global.asax, IIS7 URL Rewrite, web.config, etc., and I'm not even sure this is technically a case of url rewriting or routing... ?
You can achieve this with ASP.NET 4 routing for web forms, or if you are using MVC its available too: http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx
Except potentially for #3; it would work, but you would have to explicitly declare the variations you want. In that case, rewriting supports regular expression matching, so that might be better for what you are looking for.
I had issues setting up URL rewriting and various aspects of web forms, so be aware. There is some setup required for a rewrite module potentially (I could have done it wrong too), where URL routing is already built in and handled.
HTH.
If you have a rewrite engine available:
(using ISAPI Rewrite .htaccess syntax)
# redirect any requests for the filename back to the friendly URL
RewriteRule ^/colorWebForm4567.aspx(.*) /Color$1 [NC,R=302]
# rewrite /Color requests to the web form
RewriteRule ^/(Color|Colour)/(.*) /ColorWebForm4567.aspx$2
Following article expalins it all, but if you will be using a web host after you complete your application I would check with the hosting provider first to see if they are offering everything you need to have:
http://learn.iis.net/page.aspx/496/iis-url-rewriting-and-aspnet-routing/
Hope this helps!
As a side note: Search engines dislike it, if you publish content under different URLs ("duplicate content").
So my recommendation would be to stick with one (rewritten) URL, not multiple (rewritten) URLs for the same content.

Resources