The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Special Forums > Filesystems, Disks and Memory
Google UNIX.COM


Filesystems, Disks and Memory Questions involving NAS, SAN, RAID, Robotic Libraries, backups, etc go here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Symlinks ct1977 UNIX for Dummies Questions & Answers 1 02-21-2008 03:15 PM
Nested Symlinks? deckard Shell Programming and Scripting 0 09-07-2007 12:07 PM
search and replace symlinks nixrock UNIX for Advanced & Expert Users 2 10-19-2005 02:25 PM
.htaccess Avenger UNIX for Dummies Questions & Answers 3 04-12-2002 08:49 AM
.htaccess? Puc conDoin UNIX for Dummies Questions & Answers 1 05-28-2001 05:58 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 09-27-2007
Registered User
 

Join Date: Sep 2007
Posts: 19
.htaccess and symlinks

We give all of our members a free website, that is in this format:

http://www.mydomain.com/members/USER.../myfriend.html

But to make it easy on them we let them have a redirect to that this way:
http://www.mydomain.com/USERNAMEHERE
which redirects them to the address above.

We use .htaccess for that.
the problem is that we just opened our doors and are already over 5k members, we anticipate before the end of the year we will have closer to 100k members! That would be one HUGE .htaccess file.

Is there a better way to redirect them, possibly with symlinks?
/members is a perl script that I got to execute, which reads the first word after the / to be their username and checks if it is valid, so whatever I do, I have to keep /members as part of the URL, which symlinks could do, I think.

So would it bet better to have 250,000 symlinks or 250,000 lines of:
Redirect /USERNAMEHERE http://www.mydomain.com/members/USER.../somepage.html
which would make one LARGE .htaccess file.

I would like to thank you in advance for any kind assistance or advice you can offer for us.

Thank you.
Richard
Reply With Quote
Forum Sponsor
  #2  
Old 09-27-2007
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,610
I doubt that symlinks would work at all in this case since they would not be pointing to a filesystem object. But in any case, 250,000 directory entries of any kind is a guaranteed performance disaster. The kernel processes directories sequentially. The large file would probably win. And if there is a problem, there is more hope of optimizing the file access since that would involve changing only one program.
Reply With Quote
  #3  
Old 09-27-2007
Registered User
 

Join Date: Sep 2007
Posts: 19
So what is the best way to do this then?
Is there a way to make a particular domain, say a parked domain, that every /FirstPath run a script so I can check if it is username?

Or is there a way Unix can check in the httpd.conf file to see if the directory they entered exists, then take them there, otherwise send them to my script not just a 404.html but maintaining the directory it cannot find:

for example:
http://www.mydomain.com/foo

doesnt exists so redirect:
http://www.mydomain.com/foo/errorfile.whatever

I don't know. There has to be a way to do it to where an unlimited amount of people can access this and we not have to worry about performance. we already setup load balancing so we can add an unlimited amount of server space as the need arises, with 2 simple lines of code...

Any ideas?
thank you very much for your response.
Reply With Quote
  #4  
Old 09-27-2007
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,588
Simply use mod_rewite to rewrite and/or redirect the URLs, and inclue the rewrite rules in the apache config file instead of using .htaccess. The performance of using .htaccess for this is very sub-optimal.

Also consider load balancing based on username so that you don't create a silly number of subdirectories, as Perderabo said, your current structure is not at all scalable.
Reply With Quote
  #5  
Old 09-27-2007
Registered User
 

Join Date: Sep 2007
Posts: 19
where can I learn about 'mod_rewite', I did an advance search on this forum for it in all fourms and it only pulled up this thread

thank you.
Richard
Reply With Quote
  #6  
Old 09-27-2007
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,588
sorry that was a typo.

I meant to say mod_rewrite mod_rewrite - Apache HTTP Server
Reply With Quote
  #7  
Old 09-27-2007
Registered User
 

Join Date: Sep 2007
Posts: 19
Ok, I read all the documentation, and I thought I had a pretty good grasp on it, but apparently not... Can you tell me what I did wrong here:

Code:
# Turn on Rewrite
RewriteEngine  on
# Set the base to /members off the main domain...
RewriteBase    /members/
# Ok if the script_filename in %ENV is NOT a valid file
RewriteRule !%{SCRIPT_FILENAME} [F]
# AND if it does not already have /members
RewriteRule !%{SCRIPT_FILENAME} ^/members/
# Then go ahead and add /members to the path they are on so it works, but don't use standard redirect just do it seamlessly... AND /members already has starting / don't redo-it
RewriteRule    ^/(.+[^/])$           $1/
That does not work.
Can you tell me what I did wrong? I'd greatly appreciate it.
Richard

Last edited by reborg; 09-27-2007 at 08:12 AM. Reason: code tags
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:34 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0