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.
HELP WITH A PARTICULAR REWRITE RULE
Moderator: General Moderators
Re: HELP WITH A PARTICULAR REWRITE RULE
Any thoughts?
- prometheuzz
- Forum Regular
- Posts: 779
- Joined: Fri Apr 04, 2008 5:51 am
Re: HELP WITH A PARTICULAR REWRITE RULE
IMO, it's not possible with one rewrite rule. So you will have to use several: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.
Code: Select all
RewriteRule ^([^/]+)/?$ $1.php
RewriteRule ^([^/]+)/([^/]+)/?$ $1_$2.php
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ $1_$2_$3.php
etc.