php Pseudo Static APACHE Articles

  • 2021-06-28 11:41:30
  • OfStack

1. Check if Apache supports mod_rewrite
View the environment configuration through the phpinfo() function provided by php, and find "Loaded Modules" by Ctrl+F, which lists all the modules that apache2handler has started if it includes "mod_rewrite"is already supported and no longer needs to be set up.

If "mod_is not turned onrewrite"then open the httpd.conf file in your apache installation directory"/apache/conf/", and look for"LoadModule rewrite_through Ctrl+F"module ", delete the previous"#"number.
If not found, go to the "LoadModule" area and add "LoadModule rewrite_in the last linemodule modules/mod_rewrite.so (one line is required), then restart the apache server.

2. Support the apache server.htaccess

How can I make my local APACHE server support ".htaccess"?In fact, simply modifying the httpd.conf settings of apache under 1 will enable APACHE to support.htaccess.Open the httpd.conf file (where is it?In the CONF directory of the APACHE directory), open with a text editor and look for


Options FollowSymLinks
AllowOverride None

Change to


Options FollowSymLinks
AllowOverride All

That's it.

3. Establish.htaccess file

If it's on the windows platform, you don't know how to create it at first. htaccess file, because it doesn't have a filename, only an extension. Normally you can't create it. Don't worry, just tell you three ways: All three ways are to create a text file of htaccess.txt first (of course, you can't create a file of htaccess.txt).You can choose any name you like for this text file, and then rename it in three ways:

(1) Open it with Notepad, click Save as in the file name window, and enter "" htaccess ". Note that the whole green part, that is, contains English quotation marks, and then click Save.

(2) Enter the cmd command window, switch through cd when the folder of the htaccess.txt file has just been created, then enter the command: rename htaccess.txt.htaccess, then click the keyboard Enter key.

(3) Connect to the folder of htaccess.txt through ftp and rename it by ftp software.

4. rewrite Rule Learning

After we create a new.htaccess file, we write the following into it:


RewriteEngine on #rewriteengine For override engine switch on To open off To close 
RewriteRule ([0-9]{1,})$ index.php?id=$1

Let me explain that under 1, RewriteRule: RewriteRule is a rewrite rule that supports regular expressions. The above ([0-9]{1,}) refers to a number, $is the end sign, indicating that it ends with a number!

Okay, now we can implement a pseudo-static page, write down the rule under 1:


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index.html$ index.php
RewriteRule ^new-(\d+).html$ newxx.php?uid=$1
</IfModule>

You can implement http://127.0.0.1/index.html and http://127.0.0.1/new-1.html


Related articles: