|
|
Subject:
Apache Mod_rewrite rule needed
Category: Computers > Programming Asked by: flight554-ga List Price: $70.00 |
Posted:
01 Apr 2004 16:38 PST
Expires: 01 May 2004 17:38 PDT Question ID: 323821 |
This a question on using mod_rewrite with the Apache webserver on Linux. I want requests to one host to be served from an arbitrary physical file path. I do not want to make any additions to the httpd.conf file. This has to be done with mod_rewrite rules. All requests to http://someplace.com currently lead to /physical/filepath1 . I need to drop an .htaccess file at /physical/filepath1/.htaccess with rewrite rules that will cause all requests for http://someplace.com/whatever to be served from /otherphysical/path/whatever WITHOUT changing the address bar in the user's browser. The user will still think they are at http://someplace.com/whatever /otherphysical/path/ is on a completely different area of the webserver's drive and there is no overlap between /otherphysical/path/ and /physical/filepath . Consider both physical drive locations to be on different partitions. /otherphysical/path/ is not under the DocumentRoot from http://someplace.com/ | |
| |
|
|
There is no answer at this time. |
|
Subject:
Re: Apache Mod_rewrite rule needed
From: s3com-ga on 02 Apr 2004 03:45 PST |
Hi! You need read about Apache URL Rewriting. http://httpd.apache.org/docs/misc/rewriteguide.html Its copmlete guide to rewrite URLs with examples. On some webservers there are more than one URL for a resource. Usually there are canonical URLs (which should be actually used and distributed) and those which are just shortcuts, internal ones, etc. Independent which URL the user supplied with the request he should finally see the canonical one only. Solution: We do an external HTTP redirect for all non-canonical URLs to fix them in the location view of the Browser and for all subsequent requests. In the example ruleset below we replace /~user by the canonical /u/user and fix a missing trailing slash for /u/user. RewriteRule ^/~([^/]+)/?(.*) /u/$1/$2 [R] RewriteRule ^/([uge])/([^/]+)$ /$1/$2/ [R] Canonical Hostnames Description: ... Solution: RewriteCond %{HTTP_HOST} !^fully\.qualified\.domain\.name [NC] RewriteCond %{HTTP_HOST} !^$ RewriteCond %{SERVER_PORT} !^80$ RewriteRule ^/(.*) http://fully.qualified.domain.name:%{SERVER_PORT}/$1 [L,R] RewriteCond %{HTTP_HOST} !^fully\.qualified\.domain\.name [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/(.*) http://fully.qualified.domain.name/$1 [L,R] Regards. |
Subject:
Re: Apache Mod_rewrite rule needed
From: snapanswer-ga on 02 Apr 2004 18:07 PST |
I looked at this example, however, flight554 does not want the address to update in the browser. I think the example in the comment says it will be an external redirect and update the address. I tested some approaches, but, could not get the desired result. If I am not mistaken, if you rewrite to an external link (a link beginning with http:// for example) it will redirect and appear in the browser. At least, that's what I am coming up with. I will keep trying. |
Subject:
Re: Apache Mod_rewrite rule needed
From: jdps-ga on 07 Apr 2004 10:40 PDT |
Your question isn't very clear. From a literal interpretation, you can accomplish what you want by simply changing the DocumentRoot to point to /otherphysical/path But, in general, you can use mod_rewrite to map paths without letting the browser know. For example, RewriteRule ^/foo(.*) /full/path/to/bar/$1 will do this (note no [R] on the end!) as will a simple Alias /foo /full/path/to/bar Of course, the second one can't be used in .htaccess, and the first one may need to be adjusted for use in .htaccess. Generally, it is much simpler to use rewrite stuff in httpd.conf if you can. Also remember that you'll need to assure that /otherphysicial/path has both unix and apache permissions allowing access to the server. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |