...

View Full Version : Short URLs with similar directories



iLochie
10-02-2011, 07:26 AM
Here's what I need, I'm trying to make short urls available for users on my domain. For example: domain.com/user. Yes, this is a necessary function of my site, not just for convenience. The problem is I also have directories in my root directory that could mimic these usernames without being related at all (for example, /css or /images), see how those could both be usernames? How can I avoid this problem?

Cags
10-02-2011, 08:23 AM
Use RewriteConds to either explicitly avoid the actual URLs or perhaps more convenient, don't rewrite if the request file actually exists.


RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^([^/.]+)$ /index.php?user=$1 [L]

iLochie
10-02-2011, 08:45 AM
Use RewriteConds to either explicitly avoid the actual URLs or perhaps more convenient, don't rewrite if the request file actually exists.


RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^([^/.]+)$ /index.php?user=$1 [L]
Ahh great! Thank you, looks like I'll have to disallow certain usernames... Shouldn't be a big problem!

Cags
10-02-2011, 01:52 PM
Indeed, I meant to mention that you would have to either pre-register certain nicknames, or have a black list that isn't usable. Alternatively you could use a different subdomain allowing full usage of all paths.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum