Resolution of an invalid write Rewriterule in a. htaccess file

Source: Internet
Author: User

Recently, there was a problem with the Apache Rewrite pseudo-static configuration. Write the following:

Rewriteengine on
Rewriterule ^/t_ (. *)/$/test.php?id=$1

Found to work when saved in the httpd.conf file.

and written in the. htaccess file, it doesn't work. After research found that the random fill in the characters, the server reported 500 errors, and the orientation is not a problem, so it is not access to the problem, the initial guess should be a grammar problem. Later in Baidu "Rewriterule htaccess" when found an article, the article title: "URL Rewriterule in httpd.conf and. htaccess different points" saw:

It is important to note that the two files added to the URL rewrite rules are slightly different. These differences, for unfamiliar people, are likely to be troubled for a long time.

in httpd.conf: (1) the start of the Request URI must begin with a slash, (2) when looking for the cache file, it must be preceded by a slash, (3) when using-F or!-f, it must be preceded by a slash.

in. htaccess, the exact opposite is the case: (1) The Request URI cannot have a slash at the beginning, (2) It cannot be preceded by a slash when searching for the cache file, (3) It cannot be preceded by a slash when using-f or!-f.

Simply put, in httpd.conf, the URL before and after the rewrite needs to be preceded by a slash "/" when using an absolute path, which means that it starts at the root of the Web site and is not required in. htaccess.

Put the/Remove test OK in the. htaccess file.

Resolution of an invalid write Rewriterule in a. htaccess file

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.