Rewrite is a kind of server rewrite pulse technology, it can make the server can support URL rewriting, is a kind of latest popular server technology. It also enables the ability to restrict access to a site by a specific IP.Tools/Materials
Apache
Method/Step
rewrite flag R[=code] (Force redirect) Force external redirection G (force URL
Rewrite logo:R[=code] (Force redirect) forced External redirect F (forces URL to is forbidden) disable URL, return 403HTTP status code g (Force URL to is gone) mandatory URL is gone, return 410HTT P Status Code p (Force proxy) enforces the use of proxy forwarding L (last rule) to indicate that the current rule is the final rule, stop parsing after the rule's rewrite N (next round) re-run from the first rule
I. Notes:
1. This function has special requirements on the server environment. Independent host users need to add corresponding Rewrite rules to the Web server. Therefore, they need server permissions for use. For VM users, you need to consult your space service provider: whether the space supports Rewrite and whether the site directory is supported. the file p
Often see a lot of people for help, said his IDC does not support the Control Panel do 301 How to do, or to ask the pseudo static rules how to write, so write this blog, mainly in this article mainly discussed in Apache, to write rewrite rules.
First, let's say how the URL rewrite
Apacherewrite redirection rules, rewrite regular expressions, second-level domain names point to first-level domain names, multiple domain names point to one domain name, IP to domain name first there is a linux server, there are four IP addresses can point to this server, there are 10 domain names www.2cto. the com4 IP addresses are respectively 1.1.1.11.1.1.21.1...
Apache
A Regular expression matching, where:* ~ For case-sensitive matching* ~* for case-insensitive matching*!~ and!~* are case insensitive and case insensitiveTwo File and directory matching, where:*-F and!-f to determine if a file exists*-D and!-d to determine if a directory exists*-E and!-e to determine if a file or directory exists*-X and!-x to determine if the file is executableThree The last parameter of the rewrite directive is the flag flag, and the
The. htaccess file is no stranger to everyone. If you don't know them, search for them ...... By the way, this is a good thing and worth learning.
It seems that there are very limited tutorials on the. htaccess Programming Method on the Internet. I believe that few bloggers write their own tutorials, right?
I searched several common rules here and summarized the usage of rewrite
If these rewrite instructions are also included in the location, they are executed sequentially.
If the rewrite instruction in the location generates a new URI, the new location is determined based on the new URI. Such loops can be executed up to 10 times, and more than 500 errors will be returned after the Nginx.
The break
http://tomcat:8080/index}# the second required rule is to handle a static file request, This is nginx as the strength of the HTTP server # There are two configuration modes, directory matching or suffix matching, either one or use location ^~/static/{ root/webroot/static/;} Location ~* \. (Gif|jpg|jpeg|png|css|js|ico) $ { root/webroot/res/;} #第三个规则就是通用规则, used to forward a dynamic request to the backend Application Server # non-static file requ
Release: dedicated wait
Recently, a small site has encountered a leeching problem. As a result, the website traffic is wasted, so it is forced to install anti-leeching mechanisms for the server to save its bandwidth. G. CN and B. after CN search, several different solutions are obtained, such as the website program URL camouflage method, the server-side charging plug-in method and the ISAPI-REWRITE rule filter method. Considering the difficult problem
Remove index. php from the URL
Thinkphp, as a PHP framework, is a single portal, so its original URL is not so friendly. However, thinkphp provides various mechanisms to customize the desired URL format. In combination with the Apache. htaccess file, thinkphp can also customize a user-friendly and Seo-friendly URL address.
The. htaccess file is a configuration file on the Apache server. It is responsible for the webpage configuration under the relevant directory. We can use the
The following pseudo-static rules apply to the server for the Windows System IIS ISAPI rewrite version 2.0 for the perfect resolution of the Tipask2.5 version of the pseudo static rule. nbsp; rules such as, full-text replication can be, if there are other rules, please check whether there will be conflicts caused some
ThinkPHP uses the Rewrite rules of the. htaccess file to hide index. php in the URL and remove index. php from the URL.
ThinkPHP, as a PHP framework, is a single portal, so its original URL is not so friendly. However
ThinkPHP provides various mechanisms to customize the desired URL format. in combination with the Apache. htaccess file, ThinkPHP can also
Customized and user-friendly SEO
.
The. htaccess f
Installation of YAF
First, download the YAF installation package
PECL, enter the official PHP Extension Module website, YAF is included in the
Search: Yaf
Yaf php Framework in PHP extension, you can download various versions of the YAF installation package.
Second, decompression and installation
tar -zxvf yaf-3.0.5
The version I downloaded is 3.0.5
cd yaf-3.0.5
your/phpize/path
If you don't know your phpize path, you canfind / -name 'phpize'
./c
We need to enable rewrite Pseudo-staticSpecific operation method: log on to the KLOXO background, expand the domain name in sequence, install the WP domain name, script, and lighttpd address rewrite rule, then fill in the above rule in the input box on the right, update, after completion, remember to restart lighttpd in the service. As shown in the following figure:After configuration, restart lighttpd. Now
I (ignore case)This flag affects the rewriterule command and the corresponding rewritecond command regardless of case.F (Forbidden)Respond to the client, stop the rewriting process, and send the 403 error. Note that in this case, formatstring is useless and can be set to any non-null string.L (last rule)Stop the rewrite process here without applying any rewrite rules
Introduction to php pseudo-static URLREWRITE rewrite rules
Options FollowSymLinks
AllowOverride None
Change
Options FollowSymLinks
AllowOverride All
2. Create. create an htaccess.txt text file (of course, you can use the name of this text file as needed) in the three types of htaccess files. There are three ways to rename the file: (1) ope
$") goto "/url/%1″When the query string does not contain Sohu, and the URL ends in Zhaochou, jumping to/url/query.php?%{query_string},%{query_string} represents the query string.-Rewrite:if (query_string!~ "Sohu" Path ~ "zhaochou$") goto "/url/query.php?${query_string}"If the URL is neither a file nor a directory, jump to index.php?%{query_string}-Rewrite:if (!is_file () !is_dir ()) goto "Index.php?%{query_string}"Set the MIME type of the response headerIf the URL request file has a pdf2 extens
protected]——————————————— additional ———————————————————Modify the/min/.htaccess file if it is a formal environment, prohibit any access!Ifmodulemod_rewrite.c>Rewriteengine on# need rewritebase on some servers#RewriteBase/min#formal environment, no accessminfolder any Content! Rewritecond%{http_host} \. [NC] Rewriterule^ (. *) $/?f=$1 [l,r=301]# rewrite URLs like "/min/f= ..." to "/min/?f= ..."Rewriterule^ ([bfg]=.*) index.php?$1 [L,ne]Ifmodule>If
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.