![]() | ![]() | ![]() |
| |||||||
| Forums | Register | Groups | Awards | Arcade | Pets | T-Bucks / T-Store | Invite Your Friends | Blogs | Mark Forums Read |
| Web Design Forums and discussions on webdesign |
Web Design | |||||||||
|
|
|
|
| |||||
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| Civilians | Hi, I am a newbie in scripting and I need to write a script that will do exactly the following in functionality #===================================== RewriteEngine on RewriteBase / RewriteRule ^aaron$ /a/aaron/ [L] RewriteRule ^aaron/$ /a/aaron/ [L] RewriteRule ^andrew$ /a/andrew/ [L] RewriteRule ^andrew/$ /a/andrew/ [L] RewriteRule ^bruce$ /b/bruce/ [L] RewriteRule ^bruce/$ /b/bruce/ [L] .................. RewriteRule ^zack$ /z/zack/ [L] RewriteRule ^zack/$ /z/zack/ [L] #===================================== Is there any way to simplify the above in a couple of lines of code? There are a few thousand subdirectories that match the pattern above All data is only located in the subdirectories on the second level, the www directory looks like /home/mydomain/public_html/[a-z]/[names] Thanks! DgranD |
|
| | #2 (permalink) |
| Civilians | On 26 Oct 2004 06:58:21 -0700, Support <dimag@my-deja.com> wrote: > Hi, > > I am a newbie in scripting and I need to write a script > that will do exactly the following in functionality > > #===================================== > RewriteEngine on > > RewriteBase / > > RewriteRule ^aaron$ /a/aaron/ [L] > RewriteRule ^aaron/$ /a/aaron/ [L] > RewriteRule ^andrew$ /a/andrew/ [L] > RewriteRule ^andrew/$ /a/andrew/ [L] > RewriteRule ^bruce$ /b/bruce/ [L] > RewriteRule ^bruce/$ /b/bruce/ [L] > ................. > RewriteRule ^zack$ /z/zack/ [L] > RewriteRule ^zack/$ /z/zack/ [L] > #===================================== > > Is there any way to simplify the above in a couple of lines of code? RewriteEngine On RewriteBase / RewriteRule ^([a-z])([^/]*)/?$ $1/$1$2/ [L] .... should work. Grey -- The technical axiom that nothing is impossible sinisterly implies the pitfall corollory that nothing is ridiculous. - http://www.greywyvern.com - Orca Knowledgebase: Completely CSS styleable Knowledgebase/FAQ system |
|
| | #3 (permalink) |
| Civilians | GreyWyvern wrote: > RewriteEngine On > RewriteBase / > RewriteRule ^([a-z])([^/]*)/?$ $1/$1$2/ [L] Of course, that will also rewrite, for example, "abigail", even if there's no such person. -- Toby A Inkster BSc (Hons) ARCS Contact Me ~ http://tobyinkster.co.uk/contact |
|
| | #4 (permalink) |
| Civilians | On Tue, 26 Oct 2004 22 41 +0100, Toby Inkster<usenet200410@tobyinkster.co.uk> wrote: > GreyWyvern wrote: > >> RewriteEngine On >> RewriteBase / >> RewriteRule ^([a-z])([^/]*)/?$ $1/$1$2/ [L] > > Of course, that will also rewrite, for example, "abigail", even if > there's no such person. Just needs a RewriteCond in there to check if $1/$1$2/ exists... Grey |
|
![]() |
| Bookmarks |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| debug mod_rewrite | Sig | Web Design | 3 | 09-19-2005 08:00 |
| Help: mod_rewrite | netporter@gmail.com | Web Design | 2 | 07-09-2005 12:00 |
| Sort Solution needed | Patrick Simonds | Microsoft Applications | 2 | 03-16-2005 08:00 |
| [MV] Solution to Re: [MV] help needed to repair a plastic/polyfuel tank | Tony Mugno | MV List | 0 | 09-07-2004 22:00 |
| 'Learning M'soft Office 97' solution needed | Frogleg | Microsoft Applications | 5 | 06-16-2004 01:17 |
![]() | ![]() | ![]() |