Closed Thread Icon

Topic awaiting preservation: URL re-writing. (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12251" title="Pages that link to Topic awaiting preservation: URL re-writing. (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: URL re-writing. <span class="small">(Page 1 of 1)</span>\

 
jiblet
Paranoid (IV) Inmate

From: Minneapolis, MN, USA
Insane since: May 2000

posted posted 06-07-2002 18:05

So I am starting work on a content management system that uses Perl to take a generic HTML file and make multiple translations of the file for use in various browsers (text-only, v4- browsers, and CSS browsers). So a single page will have multiple versions mirrored in a number of parallel web root directories.

When a URL is requested, a PHP script will parse the USER-AGENT string and determine which of these directories to grab the page from, then will insert the page into a template, maybe load even more specific style information, and then output the page to the browser.

The thing about this is, it would require each page on the site to essentially be the same script. So what would be the best way to set up Apache so that URLs like:
http://www.coffman.umn.edu/url/
& http://www.coffman.umn.edu/url/?var=bleh

get translated to:
http://www.coffman.umn.edu/?path=url
& http://www.coffman.umn.edu/?path=url&var=bleh



-jiblet

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 06-07-2002 18:45

jiblet: Put something like this in your .htaccess file:

RewriteEngine on
RewriteRule /([^/]+)/([^/]+)/ /?path=$1&var=$2

which would make:

/something/otherthing/ -----> /?path=something&var=otherthing

___________________
Emps

FAQs: Emperor

jiblet
Paranoid (IV) Inmate

From: Minneapolis, MN, USA
Insane since: May 2000

posted posted 06-07-2002 23:41

Hm, simple enough, although that is not exactly what I mean. Probably more like this:

/([^\?]+)\?(.*) /?path=$1&$2

Since it's supposed to preserve a URL of any length, and concatenate passed variables so they pass through the rewrite.

I have two questions though:

Does this affect what gets written to the log? Is the original URL request logged or the rewritten URL?

What about in the browser? Does the browser actually get forwarded to this new URL or does it appear to be coming from the original URL?



-jiblet

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 06-08-2002 03:25

jiblet: Cool as long as you got it to work. To answer your questions:

1. I'm not sure I've only been playing with this properly for a week or so,

2. You get the URL that is typed in not the one that is being masked.

Have a look at the following for more mod_rewite stuff:
http://www.engelschall.com/pw/apache/rewriteguide/
http://www.heise.de/ix/artikel/E/1996/12/149/

___________________
Emps

FAQs: Emperor

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-08-2002 14:43

To redirect web browser to the new location you need to use [R] flag (read Apache documentation for more information)...

RewriteRule Pattern Substitution [R]


jiblet
Paranoid (IV) Inmate

From: Minneapolis, MN, USA
Insane since: May 2000

posted posted 06-10-2002 17:16

Ah, thanks very much guys. Yes, the default URL behavior is what i want here. Reading the documentation was most enlightening in the description of processing, especially how .htaccess processing is slow compared to adding the directives directly the httpd.conf file. Fortunately I have a dedicated Linux box all to myself and a master admin providing free support

Makes me want to learn more gory details about Apache server function

-jiblet

jiblet
Paranoid (IV) Inmate

From: Minneapolis, MN, USA
Insane since: May 2000

posted posted 06-10-2002 19:26

Alright, I've basically got this working the way I want (on a per-directory basis, although it will be inserted to the Virtual Host config as soon as I get it completely figured out).

The problem is this:

It would appear that Apache strips variables out of the URL before re-writing. The problem is, after rewriting the variables seem to be gone. Is there something I should know about propagating GET variables through rewrites? or is my problem somewhere else?

-jiblet

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-10-2002 20:05

Add %{QUERY_STRING} to the substitution pattern, where you want it to appear...


« BackwardsOnwards »

Show Forum Drop Down Menu