![]() |
|
#1
|
|||
|
|||
|
Hi everyone,
I had a few thoughts for my site/blog. I thought of copying a part of mod_rewrite of Apache. The file structure is as follows: / /blog /code /etc Each of the folders contain a content.xml page that stores the content and an attribute to whether the folder is private or not. I pick up the call using Custom 404s and then if the folder isn't private, show the content else show a 404 - Page not found message and then show the site map which is again stored in some xml file in the root. For the 404 to act in, there shouldn't be any (index|default).asp/htm/php file. But when I remove that file I get the error message - Directory browsing not allowed. Mark then told me to move the above structure in some other folder say folder 'HIDE'and then use the 404 page to display content. i got that working after sometime but then I faced a big problem. If I were to link to any asp file (any file for the matter), the call was sent to the 404 page and I had to execute it after checking whether the file existed or not. Used Server.Execute() for the same and even that worked but I faced a problem with Querystrings. As such I can't send any querystring using the same. I tried Response.Redirect but that ended up changing the address bar url to the 'HIDE' folder. This was bad because the folder was supposed to be hidden to the user. 404s had a usage cuz they provided a good link to the blog entries - 2004/12/31/ --- The main reason for me to do something like this was I felt that it would be easier to update the content of any of the sub pages and even if there was the need of an HTMLStructure to be modified, I would just have to change the 404 page. (not that I was going to have many pages )--- I have the work around to the above problem too. I'll use the directory structure as the first case and put in a Server.Transfer() for all the /folder/index.asp pages to the 404 page. All I want to know is, is this advisable? and should I go on with this kind of a thing. Or if anyone has any suggestions for something that I should go in for. Thanks and regards, Abhi |
|
#2
|
|||
|
|||
|
First of all, you shouldn't use query strings
![]() I'm not sure how this works in ASP.NET, but in PHP you can get the complete request URI. This includes the query string. - [url="http://neo.dzygn.com/"]Mark[/url:2wcnj0qocq] |
|
#3
|
|||
|
|||
|
Mark
You need to 404-hack this on IIS (unless you have an ISAPI third party add in, or an underlying, relevant file structure). On dev-x I just did something like this: [code:1xjsrn7d11] <%@ Page language="c#" %> <%@ Import Namespace="System.Text.RegularExpressions" %> <% Regex oReg = new Regex( ".+/journal/20\\d{2}/\\d{2}/\\d{2}/$" ); if( oReg.IsMatch( Request.RawUrl ) ) { Server.Transfer( "/journal/default.aspx" ); } %> [/code:1xjsrn7d11] -- Regards, Tim Scarfe <tim@developer-x.com> http://www.developer-x.com |
|
#4
|
|||
|
|||
|
Um, you have access to the original QueryString (and Form) from the file that's executed, which is the main reason why you can't pass new query strings via Server.Execute.
Odds are you'll have to make use of Session variables in order to make what you want work with straight ASP. There *are* examples in .NET for creating a rewrite engine similar to Apache's mod_rewrite (google for Rewrite.NET), so if you wanted to do your solution in .NET it is much easier. Otherwise you'll end up having to write (or buy) an ISAPI filter in C++, which is not a trivial undertaking. |
|
#5
|
|||
|
|||
|
I actually don't need any querystring for the static pages. And even if I need, for something like /code/?get=asp, the 404page is executed with a querystring itself so the url of the page that isn't found is sent to the 404page,
something like: 404;/code/?get=asp The original Querystring now contains the url i.e.: /code/?get=asp and not just ?get=asp. I can get the querystring by using the function that is used to get them while coding clientside javascript. (JS4, pg 214, David Flanagan). So this isn't much of a problem anymore. Its just that when something comes up, you guys have an expert-advice kind of a thing to say whether its good/bad and better to keep/drop. (please don't take this as sarcasm or anything else, I'm all serious) So, should I go on with this? Its quite complete and apart from the blog, I don't think I should need more than a few hours to put this up. p.s. I don't know much of mod_rewrite.i'll be using only forwarding to a single file, so, I guess I was wrong up there. sorry! ![]() |
|
#6
|
|||
|
|||
|
no comments?
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|