: .htaccess RewriteRule


RanJado
Hey,
I really don't understand this RewriteRule thing. I looked over it and only got more confusing each time.

All I want to do is basically this:
domain.com/users/username

to "become":
domain.com/username

The folder is at users/username, but I would like people to be able to access it at just /username.
So if someone goes to domain.com/username, they will get content, but from users/username, but the reader would not be the wiser.(or at least I've heard it works like this. I would like this becuase I can only give ftp accounts to users/username.)
If paths just use "path/to/users/username" and "path/to/username", and i'll just chnage it to the real paths.

So anyone out there want to help me?

thanks for any help,
-Ran Jado

Retzely
I'm not absolutely positive that this will work, but maybe it will get you in the right direction...

RewriteEngine on
RewriteCond %{REQUEST_URI} ^http://domain.com/username.*$ [NC]
RewriteRule users/username\.*$ username\.*$ [NC]

Another possibility is

Redirect permanent /users/username/.*$ http://domain.com/path/to/username/.*$

samfish
out of curiosity, what would be the purpose of setting up an FTP account on a web comic site?

i'm not saying its pointless at all. i just often wonder if theres anything i culd do w/ my FTP and user access to it.

RanJado
out of curiosity, what would be the purpose of setting up an FTP account on a web comic site?

i'm not saying its pointless at all. i just often wonder if theres anything i culd do w/ my FTP and user access to it.
I don't think I really understand your question. I have an ftp account. I can give people their own ftp account(user/pass). This is often good for people who want to share their space but don't like people knowing their password and maybe screwing them over later, and restricting that person to a folder, so they don't go bothering the other people's sites if they happen to just get pissed off.

Oh, and also, I tried the code up there in .htaccess, and when I uploaded it to the main folder, I got 403 errors on everything, even files that don't exist. So is there another place to upload it like users/user?

Retzely
Those two pieces of code are to be tried individually, not together. Were both of them giving Forbiddens? Are you sure you didn't have a [F] at the end of the line? An [F] at the end of a rewrite rule is what makes it forbidden.

I do believe you want this stuff in your top web directory .htaccess file.

Looking back at that first attempt, it looks like I might have had the Rule backwards in the last line... try this one:

RewriteEngine on
RewriteCond %{REQUEST_URI} ^http://domain.com/username.*$ [NC]
RewriteRule username\.*$ users/username\.*$ [NC]

RanJado
Those two pieces of code are to be tried individually, not together. Were both of them giving Forbiddens? Are you sure you didn't have a [F] at the end of the line? An [F] at the end of a rewrite rule is what makes it forbidden.

I do believe you want this stuff in your top web directory .htaccess file.

Looking back at that first attempt, it looks like I might have had the Rule backwards in the last line... try this one:

RewriteEngine on
RewriteCond %{REQUEST_URI} ^http://domain.com/username.*$ [NC]
RewriteRule username\.*$ users/username\.*$ [NC]
ok, that code seems like it should work, but yet it again I get 403 on all files called. I'm going to try asking my web host if somehow the RewriteEngine is disabled or something. I'm going to see if it works elsewhere as well.