Rewrite Rules in thinkphp

Source: Internet
Author: User
We know that there is a. htaccess file in the thinkphp case, which is configured with URL rewrite rules, such as RewriteEngineonRewriteCond % {REQUEST_FILENAME }! -DRewr...

We know that there is a. htaccess file in the thinkphp case, which is configured with some URL rewrite rules, such:

  1. RewriteEngine on
  2. RewriteCond % {REQUEST_FILENAME }! -D
  3. RewriteCond % {REQUEST_FILENAME }! -F
  4. RewriteRule ^ (. *) $ index. php/$1 [QSA, PT, L]

It is used to set URL rewriting to hide index. php contained in the URL. generally, URLs that are too long or dynamic are not conducive to SEO, so the purpose of hiding is to achieve better SEO effect.

Understand the role of the. htaccess file, and then let it work. to make the. htaccess file take effect, the server usually needs to enable the URL_REWRITE module for support.

The configuration process of Apache is as follows:

1. the mod_rewrite.so module is loaded in the httpd. conf configuration file.

Search for LoadModule rewrite_module modules/mod_rewrite.so in the httpd. conf configuration file (this is what Apache2 is) and remove the previous #

2. change AllowOverride None to All

In the httpd. conf configuration file, locate "AllowOverride None" and change "None" to "All. It is worth noting that "AllowOverride None" can be found in the file, but there is only one thing to change ,:

To learn how to install an integrated server environment such as wampserver or an independent installation (download and install Apache, php, and mysql respectively), follow these steps.

If your website is placed on a virtual server, you do not have the administrator permission on the server where the website content is located, or your website content is hosted on the ISP server, you cannot rewrite the main configuration file httpd. conf, what should I do? Generally, the main configuration file is httpd. conf has enabled the mod_rewrite.so module. all you need to do is find httpd in your website space. conf file (not the main configuration file, the configuration in it only works for your website), and write "AllowOverride All" to it.

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.