2016-08-10 1 views
1
RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_URI} !\.(gif|jpg|png|swf|css|html|js|ico|pdf)$ 
RewriteCond %{REQUEST_URI} !^/app.php$ 
RewriteCond %{REQUEST_URI} !^/app.php/ 
RewriteRule ^(.*)$ app.php/$1?%{QUERY_STRING} [L] 

[OK]をクリックして、良い.htaccessルールセットを作成しました。 images、html、js、cssを除くすべてのトラフィックをapp.phpというphpファイルにルーティングします。apache mod-rewriteにトップレベルのドメインが含まれていないようにする

これで、唯一のことは、末尾のスラッシュの有無にかかわらずトップレベルのドメインもapp.phpにルーティングすることです。

このルールセットにトップレベルドメインを追加するにはどうすればよいですか?

答えて

1

あなたが転送ランディングページを避けたい場合は、使用します。

RewriteEngine On 
RewriteBase/

RewriteCond %{REQUEST_URI} !\.(gif|jpg|png|swf|css|html|js|ico|pdf)$ 
RewriteCond %{REQUEST_URI} !^/app\.php(/.*)?$ [NC] 
RewriteRule ^(.+)$ app.php/$1 [L] 

.+は何もなく、ランディングページと一致します。

あなたが使用するすべてのトップレベルドメインのURLを除外したい場合:

RewriteCond %{HTTP_HOST} !^(www\.)?example\.com$ [NC] 
RewriteCond %{REQUEST_URI} !\.(gif|jpg|png|swf|css|html|js|ico|pdf)$ 
RewriteCond %{REQUEST_URI} !^/app\.php(/.*)?$ [NC] 
RewriteRule ^(.*)$ app.php/$1 [L] 
関連する問題