In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Xiaobian to share with you what htaccess pseudo-static rules are, I believe most people do not know how, so share this article for your reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!
htaccess pseudo-static rule
The.htaccess file provides a way to change configuration for directories and is a configuration file in the Apache server that is responsible for configuring web pages in the relevant directory. Through htaccess files, you can help us achieve: 301 redirect, customize 404 error pages, change file extensions, allow/block access to specific users or directories, prohibit directory lists, configure default documents and other functions.
Pseudo-static is actually using PHP to resolve the current address into another way to access the website! To learn how to write pseudo-static rules, you have to know a bit about regular rules.
Regular expressions tutorial
A brief list is as follows:
. All characters except newlines\w Match letters or numbers or underscores or Chinese characters\s Match any white space\d Match numbers\b Match beginning or end of word ^Match beginning of string $Match end of string * Repeat zero or more times + Repeat one or more times? Repeat zero or once {n} Repeat n times {n,} Repeat n or more {n,m} Repeat n to m times
Common.htaccess application examples
1 To prevent chain theft, if the user who wants to visit the url at the end of jpe jpg bmp png is not from our website, then let him see a display image of our website.
RewriteEngine OnRewriteCond %{HTTP_REFERER} !^ http://(.+.)? mysite.com/ [NC]RewriteCond %{HTTP_REFERER} !^$ RewriteRule .*. (jpe? g|gif|bmp|png)$ /images/nohotlink.jpg [L]
2 When the website is upgraded, only certain IPs can be accessed, and other users will see an upgrade page
RewriteEngine onRewriteCond %{REQUEST_URI} !/ upgrade.html$RewriteCond %{REMOTE_HOST} !^ 24\.121\.202\.30RewriteRule $ http://www.linuxidc.com/upgrade.html [R=302,L]
3 Transfer old domain names to new domain names
# redirect from old domain to new domainRewriteEngine OnRewriteRule ^(.*)$ http://www.yourdomain.com/$1[R=301,L]
III. Common Examples
For example: www.yzzmf.com/index.html-> http://www.yzzmf.com/index.php
RewriteEngine OnRewriteRule index.html index.php
For example: www.yzzmf.com/test8.html-> http://www.yzzmf.com/test.php? id=8
RewriteRule ^test([0-9]*).html$ test.php? id=$1
For example: www.yzzmf.com/cat-1-3.html-> http://www.yzzmf.com/cat.php? id1=1&id2=3
RewriteRule ^cat-([0-9]+)-([0-9]+)\.html$ cat.php? id1=$1&id2=$2
For example: www.yzzmf.com/cat-zbc2ac-3-5.html-> http://www.yzzmf.com/cat.php? id0=zbc2ac&id1=3&id2=5
RewriteRule ^cat-([a-zA-Z0-9\-]*)-([0-9]+)-([0-9]+)\.html$ cat.php? id0=$1&id1=$2&id2=$3
For example: www.yzzmf.com/cat1-4-3-8.html-> http://www.yzzmf.com/cat1.php? id1=4&id2=3&id3=8
RewriteRule ^cat1-([0-9]+)-([0-9]+)-([0-9]+)\.html$ cat1.php? id1=$1&id2=$2&id3=$3
For example: www.yzzmf.com/cat5/-> http://www.yzzmf.com/cat.php? id1=5
RewriteRule ^cat([0-9]*)/$ cat.php? id1=$1
For example: www.yzzmf.com/catm6/3/-> http://www.yzzmf.com/catm.php? id1=6&id2=3
RewriteRule ^catm([0-9]*)/([0-9]*)/$ catm.php? id1 =$1 &id2 =$2 above is htaccess pseudo-static rule is what all the content, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.