/ / mod_rewrite単純リダイレクト-apache、mod-rewrite、redirect、httpserver、ibmhttpserver

Mod_rewrite単純なリダイレクト - Apache、mod-rewrite、リダイレクト、httpserver、ibmhttpserver

私はIHSを初めて使用し、ホームページのURLをリダイレクトする必要があるという問題に直面しました。 www.example.com/foo --> www.example.com/foo/bar パスのいくつかが好きな別のもの www.example.com/foo/somethingelse 正しいです、私は多数の記事を読みましたmod_rewriteがもっと複​​雑な解決策について話していることに気付いたが、このような単純な解決策を見つけることができなかったまた、私はその正規表現についてはまだ本当に混乱しています。

助けてください、ありがとう。

回答:

回答№1は5

あなたの例では、www.example.comに設定されたHTTPホストヘッダー また、www.example.com / foo / barにリダイレクトされる/ fooまたは/ foo /のURIを持っている 次の例は、これを達成するための書き換えルールです

LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^/foo/?$ /foo/bar [R,L]

Rewritesの詳細なドキュメントは、次のサイトにあります。
http://publib.boulder.ibm.com/httpserv/manual70/rewrite/rewrite_guide.html http://publib.boulder.ibm.com/httpserv/manual70/rewrite/rewrite_guide_advanced.html


回答№2の場合は1
 <IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example..com [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{foo}
</IfModule>