Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-02-2011, 07:26 AM   PM User | #1
iLochie
Regular Coder

 
Join Date: Jan 2010
Posts: 101
Thanks: 17
Thanked 5 Times in 5 Posts
iLochie is an unknown quantity at this point
Short URLs with similar directories

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?
iLochie is offline   Reply With Quote
Old 10-02-2011, 08:23 AM   PM User | #2
Cags
New Coder

 
Join Date: Jul 2011
Posts: 67
Thanks: 0
Thanked 13 Times in 13 Posts
Cags is an unknown quantity at this point
Use RewriteConds to either explicitly avoid the actual URLs or perhaps more convenient, don't rewrite if the request file actually exists.

Code:
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^([^/.]+)$ /index.php?user=$1 [L]
Cags is offline   Reply With Quote
Old 10-02-2011, 08:45 AM   PM User | #3
iLochie
Regular Coder

 
Join Date: Jan 2010
Posts: 101
Thanks: 17
Thanked 5 Times in 5 Posts
iLochie is an unknown quantity at this point
Quote:
Originally Posted by Cags View Post
Use RewriteConds to either explicitly avoid the actual URLs or perhaps more convenient, don't rewrite if the request file actually exists.

Code:
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!
iLochie is offline   Reply With Quote
Old 10-02-2011, 01:52 PM   PM User | #4
Cags
New Coder

 
Join Date: Jul 2011
Posts: 67
Thanks: 0
Thanked 13 Times in 13 Posts
Cags is an unknown quantity at this point
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.
Cags is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 05:18 PM.


Advertisement
Log in to turn off these ads.