2014-12-19 1 views
0

리디렉션 그래서는 작품을 리디렉션하지만 (mod_rewrite를로드)

Alias /www /var/www 
<Directory /var/www> 
     Options +FollowSymLinks 
     DirectoryIndex index.php 
<IfModule mod_rewrite.c> 
     RedirectMatch /www/php/(.*) http://www.google.com/usingredirection/$1 
</IfModule> 


=> http://myserver/www/php/foo redirect to http://www.google.com/usingredirection/foo 

작동한다 RewriteRule하지 : mod_rewrite를로드 (때문에 IfModule의)와 mod_alias가 너무

하지만 RewriteRule의이

<Directory /var/www> 
     Options +FollowSymLinks 
     DirectoryIndex index.php 
<IfModule mod_rewrite.c> 
     RewriteEngine on 
     Rewritebase /var/www 
     RewriteRule ^/www/php/(.*)$ http://www.google.com/rule1/$1 [R,L] 
     RewriteRule ^(.*)$ http://www.google.com/rule2/$1 [R,L] 
</IfModule> 
작동하지 않습니다됩니다

아파치 로그에/var/www/php/foo가 없으므로 (사실인가) 하지만 재 작성이 적용되지 않는 이유는 무엇입니까?

모든 것은 * .conf 파일에 있습니다. 가 나는 htacess에 재 작성 규칙을 이동하려고하지만 난 그것에한다 RewriteEngine을 추가 자마자 항상 RewriteRule의 지시가 FollowSymLinks를 그래서 지금

에 나는 단지 경우에도 금지되어 있음을 의미하는 옵션 FollowSymLinks를 불평 또는 SymLinksIfOwnerMatch가이 꺼져 같은 PHP (기존 파일)을 제공 /www/php/*.php RewriteRule의

에게 나의 궁극적 인 목표

를 사용하여 리디렉션을 모방하려고 평소

/www /에서 PHP/미리보기/* =>/www/php/preview.php? path = $ 1

/www /에서 PHP/* =>

편집 /www/php/index.php?path=$1 : 첫 번째 설명 후, 나는 그래서 여기

을 도울 수있는 모든 물건을 게시 느낌 httpd.conf입니다. 이 파일은 저에 속한 것이 아닙니다. readyNAS Duo의 표준 conf입니다. 방금 ​​내 자신의 conf에 포함을 추가했습니다.

을 httpd.conf

ServerRoot /frontview/ui/resource/html 

... 

Listen 80 

# Please keep this LoadModule: line here, it is needed for installation. 
LoadModule perl_module /usr/lib/apache2/modules/mod_perl.so 
LoadModule auth_pam_module /usr/lib/apache2/modules/mod_auth_pam.so 
LoadModule auth_sys_group_module /usr/lib/apache2/modules/mod_auth_sys_group.so 
LoadModule apreq_module /usr/lib/apache2/modules/mod_apreq2.so 
APREQ2_ReadLimit 2147483648 
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so 
AddType application/x-httpd-php .php 
PHPIniDir /etc/php5/apache2 

ExtendedStatus On 

User admin 
Group admin 

ServerAdmin [email protected] 

Options All Indexes 
DocumentRoot /frontview/ui/resource/html 

<Files ~ "^\.ht"> 
    Order allow,deny 
    Deny from all 
</Files> 

<Files ~ "\.(js|jpg|jpeg|gif|html|htm|png|css)"> 
    Header set Pragma: public 
</Files> 

UseCanonicalName Off 
TypesConfig /etc/mime.types 
DefaultType text/plain 

<IfModule mod_mime_magic.c> 
    MIMEMagicFile share/magic 
</IfModule> 

HostnameLookups Off 

... 

<IfModule mod_autoindex.c> 
    IndexOptions Charset= 
    IndexOptions FancyIndexing NameWidth=* 
    AddIconByEncoding (CMP,/images/Icons/compressed.gif) x-compress x-gzip 
    ...more icons... 
    AddIcon /images/Pix.gif ^^BLANKICON^^ 
    DefaultIcon /images/Icons/unknown.gif 
    ReadmeName /html/AUTOINDEX.html 
    HeaderName HEADER.html 
    IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t 
</IfModule> 

<IfModule mod_mime.c> 
    AddEncoding x-compress Z 
    ...more mime... 
    AddType video/x-ms-wvx .wvx 

    AddHandler cgi-script .cgi .sh .pl 
</IfModule> 

#AddDefaultCharset utf-8 

<IfModule mod_setenvif.c> 
    BrowserMatch "Mozilla/2" nokeepalive 
    ...more browser... 
    # Drop the Range header when more than 5 ranges. 
    # CVE-2011-3192 
    SetEnvIf Range (,.*?){5,} bad-range=1 
    RequestHeader unset Range env=bad-range 
</IfModule> 

DAVLockDB /ramfs/WebDAVLock.db 
DAVMinTimeout 600 

Listen 443 
SSLEngine On 
SSL stuff ... 

# ------------------------------------------------------------------- 
# Uncomment following when more graceful error message docs are used. 
# Currently IE defaults it it's browser message, overriding any error 
# docs we create anyway. 
# ------------------------------------------------------------------- 
# ErrorDocument 401 /error/401.html 
# ErrorDocument 403 /error/403.html 
# ErrorDocument 404 /error/404.html 
# ErrorDocument 500 /error/500.html 
# Alias /error /frontview/ui/error 

<Location /> 
    Options ExecCGI 
    DirectoryIndex redirect.html index.html index.htm index.php 
</Location> 

... 

<Location /index.html> 
    SetHandler server-status 
    Order Deny,Allow 
    Deny from all 
</Location> 

Alias /images/  /frontview/ui/resource/images/ 
... 

PerlSwitches -I /etc/frontview/addons/ui 
Alias /addons/ /etc/frontview/addons/ui/ 

Alias /admin /frontview/ui/resource/html 
<Location /admin> 
    DirectoryIndex index.html 
    Options ExecCGI 
    AuthType Basic 
    AuthName "Control Panel" 
    require user admin 
</Location> 

Alias get_handler /frontview/lib 
PerlSwitches -I /frontview/lib 
PerlModule Frontview 
PerlModule get_handler 
<Location /get_handler> 
    SetHandler perl-script 
    PerlHandler get_handler 
    PerlSendHeader On 
    Options ExecCGI 
    Order allow,deny 
    Allow from all 
     AuthType Basic 
     AuthName "Control Panel" 
     require user admin 
</Location> 

Alias /np_handler /frontview/lib 
<Location /np_handler> 
    Options ExecCGI 
     DirectoryIndex np_handler.pl 
    Allow from all 
</Location> 

LoadModule listhandler_module /frontview/lib/mod_listhandler.so 
<Location /list_handler> 
    SetHandler listhandler 
</Location> 

Alias /dir_list /frontview/lib/dir_list.pl 
<Location /dir_list> 
     AuthType Basic 
     AuthName "Control Panel" 
     require user admin 
    Options ExecCGI 
    Allow from all 
</Location> 

... 

the file ends with Include /etc/frontview/apache/Virtual.conf 
which is 
<VirtualHost _default_:80> 
    SSLEngine off 
    RewriteEngine on 
    RewriteRule ^/admin$ https://%{SERVER_NAME}/admin 
    RewriteRule ^/admin/(.*)$ https://%{SERVER_NAME}/admin/$1 [R,L] 
</VirtualHost> 

은 httpd.conf에 내가 필요 있어야하는데 Rewritebase을 제거

Alias /www /var/www 
<Directory /var/www> 
     Options +FollowSymLinks 
     DirectoryIndex index.php 


     #redirecting works 
     #RedirectMatch /www/php/(.*) http://www.google.com/redirecting/$1 

     RewriteEngine on 
     #rewriterule dont work 
     RewriteRule ^(.*)$ http://www.google.com/rewriting/$1 [R,L] 
</Directory> 

내 파일의 포함로 끝납니다. 더 명확하게하기 위해 1 개의 규칙을 삭제했습니다. 는 지금은이 잡을 것으로 예상 모든 서버/WWW/PHP/* 구글로 리디렉션하지만 여전히 DocumentRoot 당신이 당신의 재 작성 규칙에서 사용해서는 안됩니다 /var/www 때문에

답변

2

작동하지 않습니다. 이 규칙을 대신 아파치에서 설정하십시오 :

<IfModule mod_rewrite.c> 
    RewriteEngine on 
    RewriteRule ^(.+?\.php)$ http://www.google.com/rule1/$1 [R,L] 
    RewriteRule ^(.*)$ http://www.google.com/rule2/$1 [R,L] 
</IfModule> 
+0

나는'Rewritebase/var/www'가 최종'/'없이는 결코 틀리지 않는다고 말할 수 있습니까? – Croises

+0

네,'Rewritebase/var/www /'는'/ var/www'가 DocumentRoot이기 때문에 여기서도 필요 없습니다. – anubhava

+1

예, 나는 또한 보았습니다. 고마워요! – Croises

관련 문제