Rewrite的规则太复杂了。研究了半天都不知道所云。只好上来请教各位了
RewriteEngine On
RewriteCond %{REQUEST_URI} !^.*(\.css|\.js|\.html|\.zf|\.gif|\.pdf|\.rar|\.ppt|\.chm|\.png|\.jpg|\.jpeg)$
RewriteRule ^(/.*)$ /index.php这些是什么意思
RewriteEngine On
RewriteCond %{REQUEST_URI} !^.*(\.css|\.js|\.html|\.zf|\.gif|\.pdf|\.rar|\.ppt|\.chm|\.png|\.jpg|\.jpeg)$
RewriteRule ^(/.*)$ /index.php这些是什么意思
楼主【pilow】截止到2008-07-07 10:47:00的历史汇总数据(不包括此帖):
发帖的总数量:1 发帖的总分数:0
结贴的总数量:1 结贴的总分数:0
无满意结贴数:1 无满意结贴分:20
未结的帖子数:0 未结的总分数:0
结贴的百分比:100.00% 结分的百分比:---------------------
无满意结贴率:100.00% 无满意结分率:---------------------
敬礼!
例子
a.gif,b.jpg.
ServerAdmin [email protected]
DocumentRoot D:\project\www\admin
DirectoryIndex index.php index.html
ServerName admin.shop
RewriteEngine on
RewriteCond %{REQUEST_URI} !^.*(\.css|\.js|\.html|\.zf|\.gif|\.pdf|\.rar|\.ppt|\.chm|\.png|\.jpg|\.jpeg)$
RewriteRule ^(/.*)$ /index.php
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot D:\project\www\web
DirectoryIndex index.php index.html
ServerName web.shop
RewriteEngine on
RewriteCond %{REQUEST_URI} !^.*(\.css|\.js|\.gif|\.jpg|\.png|\.jpeg|\.html)$
RewriteRule ^(/.*)$ /index.php
</VirtualHost> 这是apache的配置。
现在我访问admin.shop 或者web.shop都是显示admin下面的index界面。并且我访问在D:\project\www的test.php也是显示admin下面的index。为何?
不是上述最字符串结尾的请求,全部发向/index.php比如请求
/xxx/style.css 是直接请求实际文件
如果是请求
/x.jsp 或 /asdf.asp /sadf.php /sadf.xxx
全部发向/index.php
比如对于DocumentRoot D:\project\www\admin 下面有个index.php
那么我访问192.168.1.1\admin\bbbb.应该调用admin下面的index.php
而访问192.168.1.1\web\aaaa,应该调用web下面的index.php
结果我现在不论访问192.168.1.1下面的什么文件。都给我调用了admin下面的index.php
不知道是哪里的问题
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot D:\project\www\admin
DirectoryIndex index.php index.html
ServerName admin.shop
RewriteEngine on
RewriteCond %{REQUEST_URI} !^.*(\.css|\.js|\.html|\.zf|\.gif|\.pdf|\.rar|\.ppt|\.chm|\.png|\.jpg|\.jpeg)$
RewriteRule ^(/.*)$ /index.php
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot D:\project\www\web
DirectoryIndex index.php index.html
ServerName web.shop
RewriteEngine on
RewriteCond %{REQUEST_URI} !^.*(\.css|\.js|\.html|\.zf|\.gif|\.pdf|\.rar|\.ppt|\.chm|\.png|\.jpg|\.jpeg)$
RewriteRule ^(/.*)$ /index.php
</VirtualHost>
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
[/code]实现同样的效果。里边的扩展名你可以自己加。竖线被CSDN转义了~~~~郁闷。
ServerAlias exapmle.com www.example.com
即使存在多个虚拟主机也能针对每一个写rewriter这个没有问题的
1 是url重写
2 是虚拟机的配置两个请分开
RewriteEngine onRewriteRule !\.(js|ico|gif|jpg|png|css|html)$ Index.php
结果访问出现
Forbidden
You don't have permission to access / on this server.