您的位置:首页 > 其它

web配置站点访问固定文件url不变

2016-12-27 10:59 399 查看
web开发做了前后端分离后,会产生这样的需求,以oa.org为例,用户访问http://oa.org/new/xx时,服务器固定显示http://oa.org/new.html文件,文件根据url里new/后面的参数执行对应的操作。

在nginx下配置方法为:

location ^~ /new {
root /data/think/Public/;
default_type text/html;
add_header     Cache-Control "no-cache";
add_header     Pragma no-cache;
rewrite ^(.*)$ /new.html break;
}
在apache下配置方法为(xampp):

<VirtualHost 127.0.0.1:80>
DocumentRoot "D:\git_prj\think\Public"
ServerName oa.org
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/new/
RewriteRule ^/new/(.*)$ http://oa.org/new.html [P,L]

<Directory "D:\git_prj\think\Public">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

注意:apache下要让该配置生效,必需开启

LoadModule proxy_module modules/mod_proxy.so



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