Home > Backend Development > PHP Tutorial > An example of path rewriting in php URL rewrite

An example of path rewriting in php URL rewrite

WBOY
Release: 2016-07-25 09:00:04
Original
1163 people have browsed it
  1. $id=$_GET["id"];
  2. echo $id;
  3. ?>
Copy the code

First in the apache file

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

Enable rewrite and click on the "#" in front of it

2. Overload Allowoverride Find the apache configuration file and find the following:

  1. Options FollowSymLinks
  2. AllowOverride None
Copy code

Change AllowOverride None to AllowOverride All

Temporarily learned about three types of url redefinition in htaccess

  1. RewriteEngine On
  2. #RewriteBase / (If the file is in the root directory, it does not need to be defined)
  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](Enter the id directly such as localhost/ test/2 page output id=2)
  5. RewriteRule ^index.html$ index.php [NC] (Directly enter index.html to open the index.php page)
Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template