Re: can you redirect every existing html page through a php function?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: can you redirect every existing html page through a php function?

From: Stephen Kay <sk@karma-lab.nospam.com>
Date: Fri Mar 31 2006 - 06:33:21 CEST

in article C04E2935.5AC82%sk@karma-lab.nospam.com, Stephen Kay at
sk@karma-lab.nospam.com wrote on 3/27/06 11:46 PM:

>> What server are you using?
>> If you are using apache then you can use RewriteRule ... It will do exactly
>> what you are after.
>>
>> RewriteRule ^([^/]+)/([^/]+).html$ /dopage.php?p=$1 [L]
>>
>> Then you can worry about what dopage.php actually does.

Hi, I've been working on this, and it's working.

But presently, I'm doing this:

RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+).html$
/dopage3.php?p=$1/$2/$3/$4.html
RewriteRule ^([^/]+)/([^/]+)/([^/]+).html$ /dopage3.php?p=$1/$2/$3.html
RewriteRule ^([^/]+)/([^/]+).html$ /dopage3.php?p=$1/$2.html
RewriteRule ^([^/]+).html$ /dopage3.php?p=$1.html [L]

This looks really stupid to me, but I haven't come on a better syntax.

In other words, it needs the first line to redirect something like:

folder1/folder2/folder3/file.html to
/dopage.php?p= folder1/folder2/folder3/file.html

and then the next line to do

folder1/folder2/file.html to
/dopage.php?p= folder1/folder2/file.html

..etc., depending on how many layers down the html is nested.

Is there a simpler way to write this that only takes one line? I would have
thought something like this (based on my limited understanding), but it
doesn't seem to work exactly the same:

RewriteRule ^([*]).html$ /dopage3.php?p=$1.html [L]

-- 
Stephen Kay
Karma-Lab   sk@karma-lab.NOSPAM.com
                        ^^^^^^^
Received on Mon May 1 02:45:33 2006