Web 服务器 rewrite 配置
1. apache 服务器 rewrite 配置
1.1 配置虚拟域名
1.2 配置相关信息
<VirtualHost 127.0.0.2:80>
DocumentRoot "F:/Programs File/PHP suit/apache/htdocs/magento"
ServerName magento.local
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "F:/Programs File/PHP suit/apache/htdocs/magento">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
接着在配置 hosts 文件,重启
1.3 开始配置伪静态
未配置前:
RewriteEngine on
RewriteRule ^/detail/([0-9]*).html$ /detail.php?id=$1
如果有这个静态页面,如何配置,先访问静态页面,没有静态页面再访问动态页面:
<VirtualHost 127.0.0.6:80>
DocumentRoot "F:\Programs File\PHP suit\apache\htdocs\test1"
ServerName test.local
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteRule ^/detail/([0-9]*).html$ /detail.php?id=$1
<Directory "F:\Programs File\PHP suit\apache\htdocs\test1">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>