/    Sign up×
Community /Pin to ProfileBookmark

Help with a particular rewrite rule using .htaccess file

I need a regular expression to do the following:

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

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

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@stephan_gerlachOct 30.2008 — Not sure if this will work but I think it's close.
[code=php]
RewriteRule ^http://example.com/([a-z]{1})$ http://example.com/$1.php

RewriteRule ^http://example.com/([a-z]{1})/([a-z]{1})/([a-z]{1})/([a-z]{1})$ http://example.com/$1_$2_$3_$4.php

[/code]
Copy linkTweet thisAlerts:
@ck_bulletauthorOct 30.2008 — I'd like one rewrite rule to handle all instances:

blah.com/a = blah.com/a.php

blah.com/a/b = blah.com/a_b.php

blah.com/a/b/c = blah.com/a_b_c.php

etc. etc.
Copy linkTweet thisAlerts:
@ck_bulletauthorNov 05.2008 — Any thoughts?
×

Success!

Help @ck_bullet spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...