Thinkphp 在不同服務apache,nginx,iis僞靜態設置

Thinkphp 在不同服務apache,nginx,iis僞靜態設置,在linux,window不一樣,在linux 分爲apache,nginx服務,下面詳細介紹幾種設置方法。

1 在apache設置的方法

通過 .htaccess文件裏面內容爲

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
  RewriteCond %{http_host} ^huthon.com [NC]
  RewriteRule ^(.*)$ http://www.huthon.com/$1 [L,R=301]
</IfModule>

2 在nginx設置方法

通過 nginx.conf文件設置

server {
    listen  80;
    server_name   www.huthon.com;
    root /home/www/www.huthon.com;

    location /{
            index  index.php index.html index.htm;
            if (!-e $request_filename) {
                rewrite  ^/(.*)$  /index.php?s=$1  last;
            }
        }

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

}

3 在IIS設置方法

通過Web.Config文件,內容爲

<configuration>
    <system.webServer>
<rewrite>
    <rules>
        <rule name="OrgPage" stopProcessing="true">
        <match url="^(.*)$" />
        <conditions logicalGrouping="MatchAll">
        <add input="{HTTP_HOST}" pattern="^(.*)$" />
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
        <action type="Rewrite" url="index.php/{R:1}" />
        </rule>
    </rules>
</rewrite>
    </system.webServer>
</configuration>

總之不同服務,在不同平臺不一樣的。每天進步一點,開心每天

文章來自(http://www.huthon.com/)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章