Home >Backend Development >PHP Tutorial >How to set up URL Rewrite_PHP tutorial

How to set up URL Rewrite_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:58:16942browse

URL Rewrite requires server support! Before enabling this setting, please make sure that the correct settings have been made on the server. For the setting method, please refer to the "Setting Method under Apache" and "Setting Method under IIS" below!
Setting method under Apache

Copy the code The code is as follows:

Open the configuration of Apache File httpd.conf .
Remove the # in front of #LoadModule rewrite_module modules/mod_rewrite
Add in httpd.conf:

RewriteEngine On
#RewriteCond %{ENV:SCRIPT_URL} (?:index|dispbbs)[-0-9]+.html
RewriteRule ^(.*?(?:index|dispbbs))-([-0-9]+).html$ $1.php? __is_apache_rewrite=1&__rewrite_arg=$2


To implement the mapping of asp post URL to php post, in the third step, between and Add:
RewriteMap tolowercase int:tolower
RewriteCond %{QUERY_STRING} (?:boardid|page|id|replyid|star|skin)=d+ [NC]
RewriteRule ^(.*(?:index |dispbbs)).asp$ $1.php?${tolowercase:%{QUERY_STRING}}&__is_apache_rewrite=1

Save httpd.conf and restart Apache.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317645.htmlTechArticleURLRewrite requires server support! Before enabling this setting, please make sure that the correct settings have been made on the server. For setting methods, please refer to the "Setting Method under Apache" and "...
Statement:
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