I have renamed an object id and thought I'd have to write a redirection in my vhost, but after trying to access my object with the old url (the one before the object id was renamed), I saw that plone redirect me to the new object's url.
Can someone tell me which products or functionality enabled this behavior?
This functionality is provided by plone.app.redirector (http://pypi.python.org/pypi/plone.app.redirector/), which is part of the Plone core distribution.
Related
I have developed an asp.net application. I will host the application as a new website in IIS.
I want the application to work like below,
http://localhost:81/firm1/login
http://localhost:81/firm2/login
All the above 3 calls need to hit my website and I will do some process with the names 'firm1', 'firm2'.
I don't want to create multiple websites/virtual applications or sub domains.
You can use redirects from one domain to another by creating an on click event. But the best way to do it would be with Routing as mentioned in the previous answer. This is because hyperlinks generated using Routing does not require the changing of URL if the page changes its name or location.
Following this will help you to effectively use Routing:
1. Define custom URL patterns that are not dependent on physical file names.
2. Generate URLs based on route URL parameter values by using markup or code.
3. In a routed page, retrieve values passed in URL segments by using markup or code.
To add routes to a Web site, you can add them to the static Routes property of the RouteTable class by using the RouteCollection.MapPageRoute method.
Have a look at Routing in asp.net applications.
This will allow you to write modules that will receive the url of the requested page, break apart the url in components and delegate to your controllers from there.
If you already have routing set up, you will need to go through all the routes that need to sit below a 'Firm' and modify the URL they map to. For example if you have
routes.MapPageRoute("LoginRoute", "/login", "~/login.aspx")
You would change that to
routes.MapPageRoute("LoginRoute", "/{FIRM_CODE}/login", "~/login.aspx")
The routing classes will parse out the first part of the URL and make it available inside your controller as
RouteData.values("FIRM_CODE")
From there you will need to modify all your logic to handle the firm specific behaviours. You will probably want to store this value somwhere in your session state so that libraries have access to the current firm etc.
I have a web app that opens certain projects based upon a projectID
So ID 12345 = project foobar
http://my.example.com?projID=12345
However I would like to provide a different site that doesnt require the projectid, and is easier to remember for the end user.
So if a user visits
http://simple.example.com/foobar (note this is a different site, though I suppose we could put this in the same site if easier)
They would automatically get redirected to
http://my.example.com?projID=12345
Obviously I would want a system where I could have more entries than just foobar
if you don't want to use the rewrite module mentioned above you could always do it yourself by implementing a custom 404 handler and key off aspxerrorpath or perhaps putting the code in a custom httpHandler.
We actually do this with in one of our applications. We use a cms system to specify all of the redirects so nothing is really hard coded and marketers and SEO teams can handle it without our help.
in my opinion you should use ashx to handle web request. here is very simple and beautiful example of what you are looking for :-
http://www.dotnetperls.com/ashx
Building a site (in Drupal) that can only be linked to and viewed by members of a separate site (asp).
The URL to the Drupal site will only be visible to members on the asp site but I don't want them to copy and paste that URL and share it with non-members.
So... how do I make that URL constantly changing and distinct (i.e. current date?) and how do I have the Drupal site check to see that the URL is coming from the member site only?
I was thinking an .htaccess file could check for certain variables in the URL.. but A) don't know how to add a changeable variable to the URL and B) don't know the mod rewirte rule to check for that variable in the URL
Any help appreciated....
Not sure how efficient a deterrent it would be.. but time will return the current date which you can then append to your url.
Most web browsers pass the HTTP_REFERER variable by default, but in many this behaviour can be changed to not show it or to pass something else instead. There is also 3rd party anti-spyware etc software that can be installed on a user's computer which also prevents the referrer information from being passed to the web server. Because it can also be changed to something else, the HTTP_REFERER cannot be trusted, but it is still useful for working out where people have come from.
Copied from electrictoolbox.com read more here
Lets say that I have a site called
http://sub.example.com/
I want to rewrite requests so that when a user types in:
http://sub.example.com/id/company-name
It should internally be rewritten to:
http://sub.example.com/public.aspx
(I guess this is similar to the way SO question links are handled, where all questions have a unique id and a not unique title, and only the id is used to generate the page. This way an old link to a question will still work even after the title of the question has been changed)
I try to do this:
In Application_BeginRequest in global.aspx I first recognizing that the requested page is a “public” page. Then I make a
HttpContext.Current.RewritePath("~/public/default.aspx",
False)
In ~/public/default.aspx I then fetch the id to dynamically generate a company specific page (company logo and name for instance).
This is working well on my local development environment but at the server it seems that Application_BeginRequest is not triggered. I guess this is because the requested folder does not exist?
How do I solve this problem, or are there better ways to implement this behavior?
On IIS6 I used URL Rewriter (Open Source, free). On IIS 7 (or 7.5) I successfully used the URL Rewrite module from Microsoft.
In ASP.NET, how can I know whether the user has typed the default document in the URL or not—i.e., distinguish if the URL ends with / or /Default.aspx?
Nice problem :D unfortunately Request.URL.AbsoluteURI does not differentiate between the two in the default setup of IIS. IIS does a 'courtesy' redirect to the default pages existing in a web-directory, and this is done during protocol resolution -- i.e., ISAPI extensions do not see it (python framework , ASP.NET framework etc etc). You have two options :
Disable the courtesy redirect by unlisting default.aspx as default redirect, and then you will be able to use Request.URL.AbsoluteURI.
You will almost certainly not want to do this option.... Write an ISAPI filter to extract the data... perform a silent remapping (i.e., do not redirect to default.aspx, just remap the request headers') or when you redirect set a QueryString -- i.e., abc.com/default.aspx?redirected=1
p.s. this is what i get from three years of developing server plugins :/.