Any Mod Rewrite Expert care to tackle this one?

New to mod_rewrite? This is a good place to start.

Any Mod Rewrite Expert care to tackle this one?

Postby ISellOnline » Sat Jun 20, 2009 10:44 am

I want to have http://example.com/thisTopic rewrite to
http://example.com/t/h/i/thisTopic.html

where the folders t, h, and i are the first 3 letters of thisTopic (and will vary depending on the topic).

Is this possible, and what would the Apache ModRewrite statement look like?

Please, oh Mod-Rewrite Gods and Goddesses, help!

Thanks!
ISellOnline
 
Posts: 1
Joined: Sat Jun 20, 2009 10:40 am
Location: Tucson, AZ

Postby richardk » Sun Jun 21, 2009 9:33 am

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{DOCUMENT_ROOT}/$1/$2/$3/$0.html -f
RewriteRule ^(.)(.)(.).*$ /$1/$2/$3/$0.html [QSA,L]


Will they always be letters?
Will the topic only contain letters?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 117 guests

cron