Remove index.php from thinkphp

Source: Internet
Author: User

Original address: http://www.thinkphp.cn/topic/30538.html

For example, your original path is http://localhost/test/index.php/index/add.
So now the address is http://localhost/test/index/add.
How to get rid of index.php?

The mod_rewrite.so module is loaded in the 1.httpd.conf configuration file//configured in Apache

    1. #LoadModule rewrite_module modules/mod_rewrite.so To remove the siren from the front.
Copy Code

2.AllowOverride None speak none change to all//in Apache to configure

    1. <directory "D:/server/apache/cgi-bin">
    2. allowoverride None Change allowoverride all
    3. Options None
    4. Order Allow,deny
    5. Allow from all
    6. </Directory>
Copy Code

3. Make sure the Url_model is set to 2,
Write in the project's configuration file

    1. return Array(
    2. ' Url_model ' = ' 2 ',
    3. );
Copy Code

4. htaccess files must be placed in the directory with
This file adds:

    1. <ifmodule mod_rewrite. C>
    2. Rewriteengine on
    3. Rewritecond%{request_filename}!-d
    4. Rewritecond%{request_filename}!-f
    5. Rewriterule ^ (. *) $ index.php/$1 [qsa,pt,l]
    6. </IfModule>
Copy Code

Add: You can't create a file with a dot at the beginning of windows, you can just create a file
Then in DOS in Operation Rename Xxxx.xxxx. htaccess
or open Notepad to write htaccess and save As. htaccess
If a 403 error occurs, the. htaccess opens at the beginning to add options +followsymlinks
That

  1. Options +followsymlinks
  2. <ifmodule mod_rewrite. C>
  3. Rewriteengine on
  4. Rewritecond %{request_filename}- d
  5. Rewritecond %{request_filename}- f
  6. Rewriterule ^ (. *)$ index. PHP/$ [QSA,PT,L]
  7. </ifmodule>
Copy Code

can be resolved.
No permissions also add options +followsymlinks

Remove index.php from thinkphp

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.