Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mod rewrite to redirect into subdirectories by first letter

Status
Not open for further replies.

c4n

Programmer
Mar 12, 2002
110
0
0
SI
Hello,

I'm trying to get this mod rewrite working, but so far wasn't successful.

The thing is I have a folder called "viri" with a large number of files inside. To reorganize everything I am creating subdirectories a-z 0-9 and moving all files in the appropriate folder according to their first letter.

For example I am moving all files that start with "a" to /viri/a/ , all files that start with "b" to /viri/b/ etc. So
will become


Now what I'm trying to do is to redirect people visiting the old URLs to the new ones. This is the closest I think I got, but doesn't work:

Code:
RewriteEngine on
RewriteRule ^\/(\w)(.*)$ /$1/$1$2 [R=301,L]

Or

Code:
RewriteEngine on
RewriteRule ^\/viri\/(\w)(.*)$ /viri/$1/$1$2 [R=301,L]

I have the R=301 as I want this to be a permanent redirect.

Thanks in advance for any ideas or suggestions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top