您的位置:首页 > 编程语言 > PHP开发

53. PHP 伪静态(2)

2015-11-06 22:25 639 查看
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>




内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: