Форум сетевых администраторов
Показаны 2 сообщений на этой странице

Форум сетевых администраторов (http://netadmin.ws/forum/index.php)
- Apache (http://netadmin.ws/forum/forumdisplay.php?forumid=21)
-- Как настроить вэб-сервер (http://netadmin.ws/forum/showthread.php?threadid=8831)


Помещено Tagore 29-05-2004 в 18:55:

Как настроить вэб-сервер

Recipe 4.12 Displaying the Same Content on Several Addresses



Problem



You want to have the same content displayed on two of your addresses.



Solution



Specify both addresses in the <VirtualHost> directive:



NameVirtualHost 192.168.1.1NameVirtualHost 172.20.30.40<VirtualHost 192.168.1.1 172.20.30.40> DocumentRoot /www/vhosts/server ServerName server.example.com ServerAlias server</VirtualHost>





Recipe 5.5 Aliasing Several URLs with a Single Directive



Problem



You want to have more than one URL map to the same directory but don't want multiple Alias directives.



Solution



Use AliasMatch in http.conf to match against a regular expression:



AliasMatch ^/pupp(y|ies) /www/docs/small_dogs





Recipe 5.11 Replacing Text in Requested URLs



Problem



You want to change all occurrences of string1 to string2 in a request's URI.



Solution



RewriteCond %{REQUEST_URI} "string1"RewriteRule "(.*)string1(.*)" "$1string2$2" [N,PT]





Recipe 5.14 Rewriting Based on the Query String



Problem



You want to translate one URI into another based on the value of the query string.



Solution



Put this in your httpd.conf:



RewriteCond "%{QUERY_STRING}" "^user=([^=]*)"RewriteRule "/userdirs" "http://%1.users.example.com/" [R]Discussion



mod_rewrite does not consider the query string as part of the URI for matching and rewriting purposes, so you need to treat it separately. The given example translates requests of the form:



http://example.com/people?user=jones http://jones.users.example.com/ The [R] tells mod_rewrite to direct the browser to the URL constructed by the RewriteRule directive.





Recipe 5.16 Turning Directories into Hostnames



Problem



You want to migrate pathnames under a single hostname to distinct hostnames.



Solution



Use RewriteRule in httpd.conf:



RewriteRule "^/(patha|pathb|pathc)(.*)" "http://$1.example.com$2" [R]RewriteRule "^/([^./]*)(.*)" "http://$1.example.com$2" [R]RewriteRule "^/~([^./]*)(.*)" "http://$1.example.com$2" [R]Discussion



The first recipe redirects requests of the form http://example.com/pathseg/some/file.html to a different host, such as http://pathseg.example.com/some/file.html, but only for those requests in which pathseg is patha, pathb, or pathc.



The second recipe does the same thing, except that any top-level path segment is redirected in this manner.



The third recipe splits the difference, redirecting all "user" requests to distinct hosts with the same name as the user.





Recipe 6.5 Restricting Images from Being Used Off-Site



Problem



Other sites are linking to images on your system, stealing bandwidth from you and incidentally making it appear as though the images belong to them. You want to ensure that all access to your images is from documents that are on your server.



Solution



Add the following lines to the .htaccess file in the directory where the images are, or to the appropriate <Directory> container in the httpd.conf file. Replace the myserver.com with your domain name:



<FilesMatch "\.(jpg|jpeg|gif|png)$"> SetEnvIfNoCase Referer "^http://([^/]*\.)?myserver.com/" local_referrer=1 Order Allow,Deny Allow from env=local_referrer</FilesMatch>In fact, by using the following recipe, you can even go one step further, and return a different image to users accessing your images via an off-site reference:



SetEnvIfNoCase Referer "^http://([^/]*\.)?myserver.com/" local_referrer=1RewriteRule %ENV{local_referer| !1 /Stolen-100x100.png [L]Discussion



The first solution will cause all requests for image files to be refused with a 403 Forbidden status unless the link leading to the request was in one of your own documents. This means that anyone linking to your images from a different web site system will get the error instead of the image, because the referer does not match the approved server name.



Note that this technique can cause problems for requests that do not include a Referer request header field, such as people who visit your site through an anonymising service or who have their browser configured not to send this information.



The second solution is similar to the first, except that it substitutes an image of your choice for the one requested, rather than denying the request. Using the values in the Solution, you can construct a Stolen-100x100.png that has whatever admonitory message or perhaps just some picture that will deter the visitor from "stealing" your images.

__________________
Международное брачное агенство в Сибири.


Помещено w00fer 06-06-2004 в 14:39:

замутил, блин...
блин, попробуй снчала по-русски написать

__________________
Чему быть, того не миновать


Формат времени GMT. Текущее время 09:03.
Показаны 2 сообщений на этой странице

Powered by: vBulletin Version 2.2.4
Copyright © Jelsoft Enterprises Limited 2000, 2001.