httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joao Andrade" <joao6...@yahoo.com.br>
Subject [users@httpd] Regular expressions in URL rewriting
Date Sun, 12 Oct 2003 13:16:50 GMT

    Hi there folks,

    That's my very first message to the list, so excuse me if I do any
rookie mistakes. But I'll tell you, I've been through the FAQ and also read
the list archives. Let me first introduce you to the bigger problem.

    What I wanted to do was nothing fancy, my goal was to implement the
concept of "abstract url" as its defined below from an internet textbook
(http://philip.greenspun.com/internet-application-workbook/basics):

>abstract URLs
>As an engineer your primary contributions to an Internet service will be
data model and interaction design (Steps 1 through 3). When you're sketching
the page flow for a discussion >forum on a white board you give the pages
names such as "all-topics", "one-topic", "one-thread", "post-reply",
"post-reply-confirm", etc. Let's call these abstract URLs. Suppose that >you
elect to implement your service in Java Server Pages. Does it make sense to
have the URLs be "all-topics.jsp", "one-topic.jsp", "one-thread.jsp", etc.?
Why should the users see >that you've used JSP? Should they care? And if you
change your mind and switch to Perl, will you change the user-visible URLs
to "all-topics.pl", "one-topic.pl", "one-thread.pl", >etc.? This will break
everyone's bookmarks. More importantly, this change will break all of the
links from other sites to yours. That's a high price to pay for an
implementation >change that should have been invisible to end-users.
>You need a Web programming environment powerful enough that you can build
something that we'll call a request processor. This program looks at an
incoming abstract URL, e.g., >"one-topic", and follows the following logic:

  a.. is there a .jsp file in the file system; if so, execute it
  b.. look for headers requesting WML for a WAP device; if so and there is a
.wml file in the file system, serve it, if not, continue
  c.. look for a .html file
  d.. look for a .jpg
  e.. look for a .gif
(You'll want to customize the preference order for your server.)

    Now to the more specific questions:

    1. Will mod rewrite to the above, or after rewriting an URL from
http://200.155.209.19/basics/hello to http://200.155.209.19/basics/hello.php
will it show the client this last one?

    2. If the answer for "1" is yes would mod_alias be better?

    3. I tried some number of regular expressions with rewrite and none of
them have worked, I fear that there's something missing for its proper work.
I tried

        RewriteRule (.*) $1.php (the actual rule would be more complex, this
was only for test)

        and I still got a 404 error for http://200.155.209.19/basics/hello
(hello.php does exist).

    4. I've read this from a message in the list:

        > RedirectMatch .*^/obit.* http://www.delphosherald.com/obit.php
        >
        > (i.e. 0 or more any characters then anything but a "/" then "obit"
then 0 or more
        > any characters. This should match "/March.obits.html" but not
match "/obit.php".
        > Check up on regular expressions to refine it...)

        How does the program know it has to stop after inserting a .* at the
begining, doesn't it to get any character, any number of times, wouldn't it
go till the end of the line?

    5.  What's with the '^' and '$' anyway? I've seen this expression in the
docs:

        ^/$

        one tells to align at he beginning of a line and the other to align
at the end. What's the sense in of it?

        That's it I hope to have been clear enough. Thanx a lot for your
attention.

        Joao.






---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message