Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
#mod-
rewrite
1
1: mod-rewrite 2
Examples 2
Debian / Ubuntu 2
mod_rewrite 2
mod_rewrite 2
2: Apache 2.4mod-rewrite 4
Examples 4
Apache 2.4 4
RewriteBaseRewriteEngine 5
RewriteBase 5
RewriteEngine 5
RewriteMap 5
3: 6
Examples 6
PHP 6
urlphp 6
4: 7
Examples 7
8
You can share this PDF with anyone you feel could benefit from it, downloaded the latest version
from: mod-rewrite
It is an unofficial and free mod-rewrite ebook created for educational purposes. All the content is
extracted from Stack Overflow Documentation, which is written by many hardworking individuals at
Stack Overflow. It is neither affiliated with Stack Overflow nor official mod-rewrite.
The content is released under Creative Commons BY-SA, and the list of contributors to each
chapter are provided in the credits section at the end of this book. Images may be copyright of
their respective owners unless otherwise specified. All trademarks and registered trademarks are
the property of their respective company owners.
Use the content presented in this book at your own risk; it is not guaranteed to be correct nor
accurate, please send your feedback and corrections to info@zzzprojects.com
https://riptutorial.com/zh-TW/home 1
1: mod-rewrite
mod_rewriteApache。URL。
mod_rewrite.htaccess。httpd.conf。
2.2 2015717
2.4 201675
Examples
Apachemod_rewrite。
Debian / Ubuntu
a2enmod rewrite
httpd.conf
Apache。
mod_rewrite
mod_rewriteRewriteRuleRewriteCondRewriteBaseRewriteMap 。
RewriteEngine on
。mod_rewrite。。
mod_rewrite
.htaccess。httpd.conf。
AllowOverride“Fileinfo”。
AllowOverride FileInfo
https://riptutorial.com/zh-TW/home 2
AccessFileName。.htaccess。
mod_rewrite
RewriteEngine on
mod-rewrite https://riptutorial.com/zh-TW/mod-rewrite/topic/5687/mod-rewrite
https://riptutorial.com/zh-TW/home 3
2: Apache 2.4mod-rewrite
• RewriteBase URL-path
• RewriteCond TestString CondPattern
• RewriteEngine on | off
• RewriteMap MapName MapTypeMapSource
• RewriteOptions
• []
Examples
Apache 2.4
Apache 2.4mod_rewrite6
1. RewriteBase
2. RewriteCond
3. RewriteEngine
4. RewriteMap
5. RewriteOptions
6.
Apache 2.2
1. RewriteLock
2. RewriteLog
3. RewriteLogLevel
RewriteCond
RewriteEngine
RewriteMap
RewriteOptions
Everwhere
1.
2.
3.
4. .htaccess
https://riptutorial.com/zh-TW/home 4
RewriteLogRewriteLogLevelLogLevel
LogLevel rewrite:<level>
<level>trace8 emerg 。。
RewriteBaseRewriteEngine
RewriteEngine
RewriteBase
URL。
RewriteEngine
off 。。
RewriteMap
RewriteMap
RewriteCondRewriteRule
Type
https://riptutorial.com/zh-TW/home 5
3:
Examples
PHP
http://example.com/topic/id-seonameurlidphp。“” 。
RewriteEngine on
urlphp
RewriteRule 。RewriteCond。URLURL。
。 %1。([^&]*)。
https://riptutorial.com/zh-TW/mod-rewrite/topic/6162/
https://riptutorial.com/zh-TW/home 6
4:
RewriteRule。RewriteEngine on。
Examples
<Directory></Directory>。.htaccess。
RewriteRuleurl。
<Directory "/">
RewriteRule ^foo$ bar [L]
</Directory>
<Directory "/topic/">
RewriteRule ^topic/([0-9]+)-[^/]*/?$ topics.php?id=$1 [L]
</Directory>
<VirtualHost></VirtualHost>。
RewriteRuleurl。
<VirtualHost 1.2.3.4:80>
ServerName example.com
RewriteEngine on
RewriteRule ^/foo$ /bar [L]
</VirtualHost>
https://riptutorial.com/zh-TW/mod-rewrite/topic/6065/
https://riptutorial.com/zh-TW/home 7
S.
Contributors
No
Apache 2.4mod-
2 hjpotter92
rewrite
3 Sumurai8
4 Sumurai8
https://riptutorial.com/zh-TW/home 8