ホームページ  >  記事  >  バックエンド開発  >  複数のドメイン名で nginx を設定し、index.php を削除するにはどうすればよいですか?

複数のドメイン名で nginx を設定し、index.php を削除するにはどうすればよいですか?

WBOY
WBOYオリジナル
2016-08-18 09:15:511158ブラウズ

nginx如果配置去掉index.php
location /{

<code>if ($request_filename !~ (system|images|robots\.txt|index\.php.*) ) {
        rewrite ^/(.*)$ /mobile/index.php/$1 last;
    }         
}</code>

这样是可以的

因为在网站根目录下 放了好几个目录 每个目录是不同的内容
我想分别都去掉这几个 mobile app restserver apph5这几个的url路径的index.php
改怎么配置啊

这里有
www----根目录

<code>   ---mobile---    
   ---app---    
   ---restserver---    
   ---apph5---    
   </code>

回复内容:

nginx如果配置去掉index.php
location /{

<code>if ($request_filename !~ (system|images|robots\.txt|index\.php.*) ) {
        rewrite ^/(.*)$ /mobile/index.php/$1 last;
    }         
}</code>

这样是可以的

因为在网站根目录下 放了好几个目录 每个目录是不同的内容
我想分别都去掉这几个 mobile app restserver apph5这几个的url路径的index.php
改怎么配置啊

这里有
www----根目录

<code>   ---mobile---    
   ---app---    
   ---restserver---    
   ---apph5---    
   </code>

<code>if (!-e $request_filename) {
   rewrite ^/mobile/(.*)$  /mobile/index.php/$1  last;
   rewrite ^/app/(.*)$  /app/index.php/$1  last;
   rewrite ^/restserver/(.*)$  /restserver/index.php/$1  last;
   rewrite ^/apph5/(.*)$  /apph5/index.php/$1  last;
}</code>

<code>if (!-e $request_filename) {
        rewrite  ^(.*)$  /index.php?s=$1  last;
        break;
}
</code>
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。