Is it bad practice to rely on outbound rules for rewriting? - iis-7

For the past few years, if I've wanted a URL of a page on a site rewritten I've put the rewritten URL into the link on the page.
E.g. If the page is /Product.aspx?filename=ProductA and it's rewritten to /Product/ProductA.aspx then I've put the following in my link:
...
However, with outbound rules I could just put the links in to the actual file paths, and rewrite with an outbound rule.
Is this a bad method? Would it cost the server unnessacery additional resources?

I would not consider this bad practice. Infact it affords you some additional flexibility as your mapping for friendly to real url's is all managed in one central location. If your seo team decide they want to change the url scheme, you dont have to pick through all the links on your site updating them- risking missing one!
One important limitation of the current version of the IIS rewrite module, is you cannot use outbound rewriting in conjunction with Static compression- However you can still use Dynamic compression. Static compression is nice because it will cache the compressed version of the page. See this article for instructions on getting url rewrite working with Dynamic compression: http://forums.iis.net/p/1165899/1950572.aspx

Related

Next.js Rewrite: Modify response

Using Next.js's rewrite feature I would like to be able to intercept the response and change e.g. headers and even links in the body.
I have a front-facing next.js web app which is accessible by the visitors. Some parts come from a different service, but the visitor should not see those details, for her the URL should look like all comes from a single source, and all navigation goes inside the same hostname.
I used the rewrites() of next.config.js according to Incremental adoption of Next.js and this works for the most part. But the responses from the other background service sometimes contain wrong URLs / hostnames. Those I would like to replace to match the public facing hostname of the web site.
I couldn't find any pointers on the next.js documentatin as to how best approach this problem. Maybe someone has a solution to share or there exist some middleware already?
Rewrites are simply a way to map a request path to a different destination path. Rewrites don't allow you to modify the contents of the page you're rewriting to.
You'll have to modify the destination app yourself to reflect the changes you want.

URL Routing to page with same name

I have a currently existing site with URL re-writing enabled using ISAPI Rewrite and IIRF files, the problem is it's causing a lot of problems, both for site development / maintenance and because of continuous errors on the server.
Because of this I'm looking to replace it with .Net 4.0's URL Routing.
I'm having two problems with this, first, the current routing rules are set up so that the page being routed to is simply the re-written URL with the file extension appended to the end.
So www.site.com/page/ would become www.site.com/page.aspx
The second problem is that certain re-written URL's actually point to physical files within sub-folders on the website using the same logic as above.
So www.site.com/folder/page/ would redirect to www.site.com/folder/page.aspx
I've read through this article and created custom IRouteHandler and IHttpHander implemented classes, but I'm not really sure where to go from here.
I've tried a few different things, mainly related to variables in the URL and trying to redirect to them, but I'm not sure that's the right way for me to go.
I'm not posting code because all I have at the moment is pretty much the example code from the link above.
I've implemented basic routing on another site where a single page uses a variable in the URL to grab the relevant content out of a database, and that seemed simple enough, but this is making my head spin, I'm sure it shouldn't be this complicated.

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.

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.

Where content based websites store their content?

Sites like cnn.com or foxnews.com.
Where do they store all the articles? In html files? In database?
More logically to store everything in DB but how to generate a static link to something that is inside DB?
It's not that they have a a dynamic page load like: LoadArticle.aspx?ArticleID=123, every article has it's own address.
Please explain how this is done.
They use a special content management library called VoodooLib.dll.
Seriously, when you write something to a database, you normally generate some kind of unique identifier - 123, for example. It gets permanently associated with that record (article content). After that it is used to generate the same id as part of an Url at any time later.
As for the static link, it is a simple matter of Url Rewriting.
You generate static links to display on a page because they work much better for SEO. When a request for that static Url hits the server, it gets substituted for something "server friendly" and then gets to be processed.
They probably use some form of Content Management System (CMS). There are many different ones out there - most store the actual content in a database or as XML (some store XML in a database). They will the either publish that content as static HTML pages or, more commonly now, as dynamic pages that are cached. Many use what are known as "friendly URLs" that are virtual addresses that are mapped to the actual physical file path using URL-rewriting techniques.
Note you can't tell whether a page is dynamic or static simply from the extension. It is quite possible to have dynamic pages that end in the .html extension.
Just because the URL looks "static" doesn't mean it is; they could be using something like mod_rewrite or an IIS ISAPI to make the URLs more search engine friendly.
For the high-volume news sites that you mention, however, they may very well generate the pages statically in order to prevent overloading the database with repeated requests for the same article.
Look at the URl of this page, it doesn't have xxx.aspx?some-query-string
You are refering to using friendly URLs.
To do something like that, one common way is to use URL Rewrite and/or some custom HTTPModule
Here's a good reference: http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
Just because a page has a normal URL does not mean that it isn't serving dynamic content. With the Apache mod_rewrite module, it is possible to manipulate URLs. So, for example, a page like http://www.domain.tld/permalink/12345/message-title-slug can be converted internally to http://www.domain.tld/permalink/index.php?id=12345&slug=message-title-slug.
I do not know exactly what cnn.com and foxnews.com use, but I would bet that they use a Content Management System (CMS) which serves all pages dynamically, with the content stored either in a database or on the filesystem, and with authoring/publishing all being performed through the particular CMS.
Just checking cnn.com, the article links have in them
Year
Location (US or WORLD/specificlocationid)
Month
Day
Article name.
All of this information together can be used to uniquely identify any article (even less of it is probably actually needed). The dynamic content loading page address could easily be hidden by some method of URL rewriting, and then the information in the requested URL is used to determine which article in the DB is to be served up.
I don't know why all the other answerers seem to assume that some form of URL rewriting is necessary to create friendly URLs. It's not true at all.
It's perfectly possible to write web serving code that splits a URL into parameters - eg year, month, title - and pass that directly to the code that gets the content from the database, without any need to rewrite the URL. Most modern web frameworks such as Django and Rails include this functionality out of the box.
This is done through mod-rewrite techniques.
Here's an article about the mod rewriting engine: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
And here's their "guide": http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
I hope that helps. It should make for a good starting point. Goodluck.

Resources