mod_rewriteの正しい指示を作成する際に助けてください。それは非常に難しいようです。mod_rewriteの複雑なルール
私は正確に以下が必要:www.site.comにsite.comから
1. リダイレクト。
www.site.com/hello ==> site.com/hello
www.site.com/abc/def ==> site.com/abc/def
などとし、他の規則を適用する必要があります。
2.(などのrobots.txt、画像/、など)いくつかの指定されたファイルやフォルダへの直接アクセス(無リライト)
たぶん
RewriteCond %{REQUEST_URI} !^/(robots.txt|favicon.ico|images|documents|~.\*)
私は右ですか?
site.com/robots.txt ==> site.com/robots.txt
site.com/documents/file1.pdf ==> site.com/documents/file1.pdf
のようなURLはそのままで、書き換えないでください。
3.別の変換:
site.com/index.php?anythinghere ==> site.com/a/index.php?anythinghere
4.しかし、我々は入力した場合のURL site.comとApacheは(site.com/index.php)ルートフォルダでのindex.phpを呼び出す必要がありますsite.com/
site.com ==> site.com/index.php
site.com/ ==> site.com/index.php
5.私は、MVCのスクリプトを持っている、と我々は次のURLを入力した場合:
1. site.com/controller or site.com/controller/ or site.com/controller//
2. site.com/controller/function or site.com/controller/function/
3. site.com/controller/function/parameter or site.com/controller/function/param1/param2/param3
とコントローラがリスト内の定義済みの単語の1つ、たとえば "index"、 "news"、 "contacts"(多分数百語に拡張されるかもしれません)の場合は、index.phpを呼び出し、以下の方法:
site.com/controller ==> site.com/index.php?q=controller
site.com/controller/ ==> site.com/index.php?q=controller/
site.com/controller// ==> site.com/index.php?q=controller//
site.com/controller/function ==> site.com/index.php?q=controller/function
site.com/controller/function/ ==> site.com/index.php?q=controller/function/
site.com/controller/function/parameter ==> site.com/index.php?q=controller/function/parameter
site.com/controller/function/param1/param2/param3 ==> site.com/index.php?q=controller/function/param1/param2/param3
6.そして、以前のすべてのルールが適用されなかった場合、最終的に、私たちは希望Apacheが再帰的でmod_rewriteを使用していない、または私は巨大な悩みを持っています
site.com/anythinghere ==> site.com/a/index.php?anythinghere
を書き換える必要があります別のindex.phpで
私はそれが容易ではないことを理解しますが、1つのアイテムでもルールを作成することができれば、それは素晴らしいことです。
ありがとうございます!あなたは.htaccessファイルにこれらの行を置くことができ最初リライトの
私はあなたの質問を少し編集して、変換をより明確にしました。それが役に立てば幸い。 –
ありがとうございました!それは今より良いです。 – user1373539