|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Mod_rewrite question, I think.
Is it possible to (rewrite and) forward, a request like http://domain.com/~something/ to http://domain.com/somethingelse/something/
You don't have to give me any pretty code, I like finding out on my own. But it's nice to know if it's possible or not. |
|
#2
|
|||
|
|||
|
Yes and it works with both internal/external redirect.
|
|
#3
|
|||
|
|||
|
Okay, thanks.
Now I've used: RewriteEngine on RewriteRule ^/~(.+) http://domain/usr/$1 [R,L] But e.g. http://domain/~apa doesn't redirect to http://domain/usr/apa mod_rewrite IS loaded, but no errormsgs. Any idea? |
|
#4
|
|||
|
|||
|
>> doesn't redirect to http://domain/usr/apa
Can you access http://domain/user/apa/ directly? Your rulesets look absolutely fine. The question is how you handle UserDir. BTW you don't even need to use /~apa at all. If you need internal redirect, just change your ruleset to: RewriteEngine on RewriteRule ^/~(.+) /server/path/usr/$1 [L] |
|
#5
|
|||
|
|||
|
Now I had some time over and thought I'd give it a go again. Rewrote it to use internal redirect instead;
RewriteRule ^/~(.+) /usr/local/www/burkmatnu/www/usr/$1 [L] where /usr/local/www/burkmatnu/www/ is the absolute path to the public www. Still doesn't work though. Have I missed something really simple and that's why it wont work? I've put the lines in a htaccess-file in the www-root; could that be the problem? |
|
#6
|
|||
|
|||
|
You still haven't replied to my previous question.
>> I've put the lines in a htaccess-file in the www-root Don't even do that, just put that in httpd.conf within <Directory "/usr/local/www/burkmatnu/www"> |
|
#7
|
|||
|
|||
|
If the question was "Can you access http://domain/user/apa/ directly?" Then it's 'yes'. If it was "how you handle UserDir", then I have no idea. It's not my server, so I don't have access to httpd.conf. It [the mod_rewrite] works great at home, but since I'm on dialup I can't really run a 24/7 website on it.
|
|
#8
|
|||
|
|||
|
>> If it was "how you handle UserDir", then I have no idea. It's not my server
Then you can't do it in .htaccess because UserDir is not overridable. You can't use mod_rewrite to intercept the ^/~username/ URI when UserDir is enabled. There would be a serious security flaw when you do this in .htaccess: RewriteEngine on RewriteRule ^/~(.+) /server/path/usr/$1 [L] where the (.+) is another user's docroot that now lives under your docroot with a -Indexes. Last edited by freebsd : February 28th, 2002 at 01:58 PM. |
|
#9
|
|||
|
|||
|
Okay, I understand that would be a huge security flaw. Thanks for pointing it out.
Am I to understand that if one would use external redirects in .htaccess instead, the flaw would sieze to exist? Or am I just being foolish? |
|
#10
|
|||
|
|||
|
External is a little safer though. But really, you need to disable UserDir or change UserDir to a URI other than ^/~username/ else you can't override it.
|
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > Mod_rewrite question, I think. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|