PHP URL rewrite path rewrite example

Source: Internet
Author: User
    1. $id =$_get["id"];
    2. echo $id;
    3. ?>
Copy Code

First in the Apache file

Open the Apache configuration file httpd.conf and find the following: #LoadModule rewrite_module modules/mod_rewrite.so

Turn on the rewrite and go to the front "#".

Second, overload allowoverride find the Apache configuration file as follows:

    1. Options FollowSymLinks
    2. AllowOverride None
Copy Code

Change allowoverride None to allowoverride all

Three types of URL redefinition are temporarily known in htaccess

    1. Rewriteengine on
    2. #RewriteBase/(if the file does not have to be defined in the root directory)
    3. #RewriteRule ^t_ (. *). html$ test.php?id=$1 [NC] (open test.php to t_id.html such as t_2.html page output id=2)
    4. Rewriterule ^ ([0-9]+) $ test.php?id=$1 [NC] (direct input ID such as LOCALHOST/TEST/2 page output id=2)
    5. Rewriterule ^index.html$ index.php [NC] (direct input index.html can open index.php this page)
Copy Code
  • 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.