Go Back   Trackpads Community > General Discussions > Computer and Technology > Web Design

Web Design Forums and discussions on webdesign

Web Design

Reply
 
LinkBack Thread Tools
Old 10-26-2004, 12:00   #1 (permalink)
Support
Civilians

 
Default Mod_rewrite: clean solution is needed

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
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Trackpads Information
Click to Visit
Old 10-26-2004, 12:00   #2 (permalink)
GreyWyvern
Civilians

 
Default Re: Mod_rewrite: clean solution is needed

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
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-26-2004, 20:00   #3 (permalink)
Toby Inkster
Civilians

 
Default Re: Mod_rewrite: clean solution is needed

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

 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-26-2004, 20:00   #4 (permalink)
GreyWyvern
Civilians

 
Default Re: Mod_rewrite: clean solution is needed

On Tue, 26 Oct 2004 2241 +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
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


Community Information
Options
Quick Options
Trackpads Non-Commercial Ad
Copyright Information Click to Visit
Time
Server Time
All times are GMT -4. The time now is 09:32.
Copyright
Copyright Information
The header is based off of work by Vipixel.com and modified by this site. Trackpads and the Trackpads Logo are both Registered Trademarks of Jason Edwards and cannot be used without prior written permission.  The only exception is as a link back to this site. Trackpads is a private website run by a small legion of volunteers, 3 dogs, 12.5 cats and an army of small, super smart, bio-engineered mice with pointy hats and tutu's. Search Engine Friendly URLs by vBSEO 3.2.0 RC7
Archive Links
Archive Links
Page generated in 0.79513 seconds with 19 queries