Page 1 of 1

HELP WITH A PARTICULAR REWRITE RULE

Posted: Wed Oct 29, 2008 1:48 pm
by bulletck
I need a regular expression to do the following:

if someone goes to http://example.com/a the actual served page is http://example.com/a.php

and also http://example.com/a/b/c/d to render http://example.com/a_b_c_d.php, etc.

Re: HELP WITH A PARTICULAR REWRITE RULE

Posted: Wed Nov 05, 2008 1:42 pm
by bulletck
Any thoughts?

Re: HELP WITH A PARTICULAR REWRITE RULE

Posted: Wed Nov 05, 2008 1:56 pm
by prometheuzz
bulletck wrote:I need a regular expression to do the following:

if someone goes to http://example.com/a the actual served page is http://example.com/a.php

and also http://example.com/a/b/c/d to render http://example.com/a_b_c_d.php, etc.
IMO, it's not possible with one rewrite rule. So you will have to use several:

Code: Select all

RewriteRule   ^([^/]+)/?$                   $1.php
RewriteRule   ^([^/]+)/([^/]+)/?$           $1_$2.php
RewriteRule   ^([^/]+)/([^/]+)/([^/]+)/?$   $1_$2_$3.php
etc.