Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite, with a unknown filename

mod_rewrite unknown filename

         

ddans

11:50 am on Mar 7, 2004 (gmt 0)



Hi,

I'm looking for some advice/pointers on how I can accomplish this (if possible).

pagea.html?page=1 -> /pagea/1.html
pageb.html?page=2 -> /pageb/2.html

The above rewrite is no problem, however the following page might also exist.

someotherpage.html?page=7 -> /someotherpage/7.html

So the issue is that I have no set of fixed filenames to list in my .htaccess

I probably use a condition check, see if there's a
?page= parameter but I am lost with the "dynamic" filename.

If anyone could shed some light if this is possible,
I would be very gratefull.

Regards,
Ddans

hyperbole

11:20 pm on Mar 7, 2004 (gmt 0)

10+ Year Member



What does your .htaccess file look like?

jdMorgan

1:29 am on Mar 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ddans,

Welcome to WebmasterWorld [webmasterworld.com]!


RewriteCond %{QUERY_STRING} ^page=([0-9]+)
RewriteRule ^(.*)\.html$ /$1/%1.html? [L]

$1 back-references the contents of the first parenthesized subpattern in the RewriteRule pattern. %1 back-references the contents of the first parenthesized subpattern in the RewriteCond.

Jim