0

非常に単純なapache書き換えルールに何時間も苦労しています。それは私がもうそれを見ることができないほど明白であるに違いありません。

入力として、ブラウザに入力します。

http://enseignement2.be/deployment.html

このページを表示しようとしています:

http://enseignement2.be/hello.html

そこで、そのルールをapacheconfファイルに追加しました。

RewriteRule ^deployment\.html$ hello.html [L,NC,QSA,R=301]

...そして実際には他の多くの変種。その結果、deployment.htmlページが表示されます。ブラウザのURLは変更されません。

これは私の完全な構成ファイル、/ etc / httpd /conf.d/にあるenseignement2.confです。

 <VirtualHost 68.169.61.167:80>
     ServerName enseignement2.be
     DocumentRoot /var/www/hagakure/data/www/
     SuexecUserGroup hagakure hagakure
     CustomLog /var/www/httpd-logs/enseignement2.be.access.log combined
     ErrorLog /var/www/httpd-logs/enseignement2.be.error.log
     ServerAlias *.enseignement2.be www.enseignement2.be
     AddDefaultCharset UTF-8
 # enable expirations
     ExpiresActive On
 # expire GIF,JPEG,PNG images after a month in the client's cache
   ExpiresByType image/gif A2592000
   ExpiresByType image/jpeg A2592000
   ExpiresByType image/png A2592000

   ExpiresByType application/javascript A2592000
   ExpiresByType text/css A2592000

   RewriteEngine on
 #       RewriteCond %{HTTP_HOST} ^(.+)\.enseignement(2|deux)\.be [NC] # only if there is something (at lease 1 char) before the first dot. example: toto.enseignement2.be
 #       RewriteRule     ^(.*)?$ http://enseignement2.be$1 [redirect=301,nocase]
         RewriteRule ^deployment\.html$ hello.html [L,NC,QSA,R=301]

 # Directives for eApps applications dependent on Apache
    ProxyPass /deployment.html !
    ProxyPass /deployment.jpg !
    ProxyPass /hello.html !
    ProxyPass /manager/ispmgr !
    ProxyPass /manimg !
    ProxyPass /mancgi !
    ProxyPass /webmail !
    ProxyPass /joomla !
    ProxyPass /awstats !
    ProxyPass /myadmin !
 # Directives for your application
    ProxyPass / ajp://localhost:8009/
    ProxyPassReverse / ajp://localhost:8009/
 </VirtualHost>

ProxyPass /deployment.html!という行にコメントを付けると、ページが表示されなくなるため、ProxyPassが考慮されます(要求はapacheの背後にあるtomcat7インスタンスに転送されます。

CentOS 6、Apache / 2.2.22で動作します。どんな提案でも歓迎します、ありがとう!

4

1 に答える 1

0

サーバー/仮想ホスト構成では、正規表現の先頭にスラッシュが必要です。

RewriteRule ^/deployment\.html$ hello.html [L,NC,QSA,R=301]
于 2012-10-03T18:19:50.053 に答える