0
我用一個非常簡單的apache重寫規則打了幾個小時。它一定很明顯,我再也看不到它了。apache RewriteRule將頁面重定向到根目錄不起作用
作爲輸入,我在瀏覽器中輸入:
http://enseignement2.be/deployment.html
我儘量讓這個頁面顯示:
http://enseignement2.be/hello.html
所以,我補充說,規則在Apache的conf文件:
RewriteRule ^deployment\.html$ hello.html [L,NC,QSA,R=301]
...和其他許多變種實際上。 因此,它顯示了deployment.html頁面。瀏覽器的URL保持不變。
這是我的完整的配置文件,enseignement2.conf在/etc/httpd/conf.d/
<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都考慮在內,因爲如果我評論了線的ProxyPass /deployment.html! ,頁面不顯示了(請求被轉移到後面的Apache Tomcat的7實例。
它運行在CentOS 6,使用Apache/2.2.22 任何建議是值得歡迎的球員,非常感謝!
非常感謝你這是很好的工作 – maxime