DHTML Forum  

Go Back   DHTML Forum > dhtmlcentral.com > Off-topic
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05.02.2004, 04:35
Abhi Abhi is offline
Erfahrener Benutzer
 
Join Date: 13.07.2001
Location: India
Posts: 1.626
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 05.02.2004, 15:20
Mark Mark is offline
Erfahrener Benutzer
 
Join Date: 28.02.2002
Location: Netherlands
Posts: 2.853
Default

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]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 05.02.2004, 16:04
Tim Scarfe Tim Scarfe is offline
Erfahrener Benutzer
 
Join Date: 14.05.2001
Location: United Kingdom
Posts: 1.015
Default

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4  
Old 05.02.2004, 19:06
ttrenka ttrenka is offline
Erfahrener Benutzer
 
Join Date: 10.11.2001
Location:
Posts: 1.005
Default

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5  
Old 06.02.2004, 02:52
Abhi Abhi is offline
Erfahrener Benutzer
 
Join Date: 13.07.2001
Location: India
Posts: 1.626
Default

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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6  
Old 07.02.2004, 14:52
Abhi Abhi is offline
Erfahrener Benutzer
 
Join Date: 13.07.2001
Location: India
Posts: 1.626
Default

no comments?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

All times are GMT +2. The time now is 03:16.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.