Thinkphp hides index. php

Source: Internet
Author: User
To achieve better SEO optimization, we need to hide the index in the URL address. php, because the configuration methods of different server environments are quite different, we can refer to 5.9URL rewriting for the configuration under the apache environment, so I will not talk about it. here I will explain IIS and Nginx.

To achieve better SEO optimization, we need to hide the index in the URL address. php, because the configuration methods of different server environments are quite different, we can refer to 5.9 URL rewriting for the configuration in the apache environment, the following describes the basic configuration methods and ideas under IIS and Nginx.

IIS environment

If your server environment supports ISAPI_Rewrite, you can configure the httpd. ini file and add the following content:

RewriteRule (. *) $/index \. php \? S = $1 [I]

In the later version of IIS, you can configure web. Config and add a rewrite node in the middle:

  1. Name = "OrgPage" stopProcessing = "true">
  2. Url = "^ (. *) $"/>
  3. LogicalGrouping = "MatchAll">
  4. Input = "{HTTP_HOST}" pattern = "^ (. *) $"/>
  5. Input = "{REQUEST_FILENAME}" matchType = "IsFile" negate = "true"/>
  6. Input = "{REQUEST_FILENAME}" matchType = "IsDirectory" negate = "true"/>
  7. Type = "Rewrite" url = "index. php/{R: 1}"/>

Nginx environment

In earlier versions of Nginx, PATHINFO is not supported, but you can configure forwarding rules in Nginx. conf:

  1. Location /{//..... Partial code omitted
  2. If (! -E $ request_filename ){
  3. Rewrite ^ (. *) $/index. php? S = $1 last;
  4. Break;
  5. }
  6. }

In fact, it is forwarded to the compatible URL provided by ThinkPHP. this method can be used to solve other WEB server environments that do not support PATHINFO. if your ThinkPHP is installed in the second-level Directory, the pseudo-static method of Nginx is set as follows, where youdomain is the directory name.

  1. Location/youdomain /{
  2. If (! -E $ request_filename ){
  3. Rewrite ^/youdomain/(. *) $/youdomain/index. php? S = $1 last;
  4. }
  5. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.