RewriteEngine On                                                        #设置是否开始rewrite
RewriteBase / #设置开始匹配的目录,比如web程序放在/var/www/html/test下,则这个值要设置为"/test" #只用www的域名
RewriteCond %{HTTP_HOST} ^test.com$ [NC] #RewriteCond设置匹配条件,即对服务器变量中的哪个值进行匹配
RewriteRule ^(.*)$ http://www.test.com/$1 [L,R=301] #RewriteRule设置匹配成功后要执行的动做。即匹配成功后要把url映射到哪一个url # 需要301的页面
RewriteCond %{QUERY_STRING} ^.*news_id=(.+)$ #对查询字符串进行匹配,这里通过正则匹配到的值在下面使用时用"%"使用,如"%1"
RewriteRule ^news\.php.*$ redirect.php?type=news&id=%1 [L] #将匹配到的url路径(tab前的)重写为新设置的路径(tab后的),这里通过正则匹配到的值在下面使用时用"$"使用,如"$1" #重写规则可单独使用
RewriteRule ^.*map\.php.*$ other/map.html [L] #网站地图
RewriteRule ^.*questions\.php.*$ service/fqa/ [L] #问题解答栏目 #规范应用的入口,只能通过index.php访问
RewriteCond %{SCRIPT_FILENAME} !index\.php$ [NC]
RewriteCond %{SCRIPT_FILENAME} !test\.php$ [NC]
RewriteCond %{SCRIPT_FILENAME} !code\.php$ [NC] #后台验证码
RewriteCond %{SCRIPT_FILENAME} !redirect\.php$ [NC] #原网站301重定向文件
RewriteRule ^(.*\.php.*)$ http://www.test.com/ [L,R=301] # 下载文件保护
RewriteCond %{REQUEST_FILENAME} \/uploadfile\/download.*$ [NC]
RewriteRule ^(.*)$ http://www.test.com [L,R=404] # 网页模版保护
RewriteCond %{REQUEST_FILENAME} \/templates\/default/cn.*$ [NC]
RewriteRule ^(.*)$ http://www.test.com [L,R=404] ========================
#LazyREST的.htaccess
RewriteEngine On
RewriteBase /LazyREST
RewriteRule ^api/(.+)/(.+)/(.*)$ index.php?c=api&_table=$1&_interface=$2&$3 [L]

关于.htaccess的设置的更多相关文章

  1. .htaccess文件设置

    1.为使.htaccess有效,需要先做httpd.conf设置 #打开改写模式Options FollowSymLinks AllowOverride All#打开重写模式,去掉这行注释LoadMo ...

  2. Apache服务器如何通过.htaccess文件设置防盗链?

    Apache服务器通过.htaccess文件设置防盗链 用户经常面对的一个问题就是服务器的流量问题,而站点文件被盗链是其中最为主要的部分.所谓盗链,是指其他网站直接链接我们网站上的文件,一般来说,盗链 ...

  3. Apache 中 .htaccess 文件设置技巧16则

    .htaccess 文件 (Hypertext Access file) 是Apache Web服务器的一个非常强大的配置文件,对于这个文件,Apache有一堆参数可以让你配置出几乎随心所欲的功能.. ...

  4. http跳转htts的htaccess文件设置

    RewriteEngine OnRewriteCond %{SERVER_PORT} 80RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]Options ...

  5. htaccess分布式配置文件常用写法

    htaccess 写法 Apache中的.htaccess(或者”分布式配置”了针对目录改变配置的方法,即,在特定的文档目录中放置包含或多个指令的,以作用于此目录及其子目录.作为,所能的命令受到限制. ...

  6. apache开启.htaccess及.htaccess的使用方法(转)

    apache开启.htaccess及.htaccess的使用方法 作者: 字体:[增加 减小] 类型:转载 时间:2010-12-02 今天本地调试PHP程序,用到了.htaccess,而默认配置里面 ...

  7. apache开启.htaccess

    1 . 如何让的本地APACHE开启.htaccess 如何让的本地APACHE开启.htaccess呢?其实只要简朴修改一下apache的httpd.conf设置就让APACHE.htaccess了 ...

  8. Nginx环境中如何将HTTP跳转至HTTPS设置

    如果我们VPS服务器的WEB环境采用的是NGINX架构,那如果我们将安装SSL证书的网站希望强制跳转至HTTPS网站URL的时候那需要如何设置呢?这里个人建议是这样的,我们必须要强制一个地址,这样网站 ...

  9. mac下为Apache 创建 .htaccess文件

    标签:mac   .htaccess 在设置固定链接时会提示如下的问题:   若您的 .htaccess 文件可写,我们可以自动修改它.但似乎它不可写,因此我们在下方列出了您 .htaccess 文件 ...

随机推荐

  1. 基于Extjs 4.2的通用权限管理系统,通用后台模板,EF+MVC+Extjs 4.2

    基于Extjs 4.2的通用权限管理系统,通用后台. 我们的宗旨:珍爱生命,拒绝重复!Don't Repeat Yourself!!! 本案例采用EntityFramework+MVC4.0+Extj ...

  2. java二叉树字典查询(qq 928900200)

    This assignment will help you practice and understand better the Binary Tree and Binary Search Tree ...

  3. 在windows下安装git后没有ssh文件夹

    在windows7下安装git后,运行 cd ~/.ssh $ bash: cd: /c/Users/Administrator/.ssh: No such file or directory 出现以 ...

  4. Path expected for join!错误处理

    在Hibernate中,进行连接查询时,如果使用join语句,就容易产生标题所示的错误. 比如from Content o left join Mcp mcp where o.mcp.id=mcp.i ...

  5. vmware-hostd.exe 占用443端口导致Apache无法正常启动?

    问题: [Apache]  Problem detected!16:23:19  [Apache]  Port 443 in use by ""D:\vmware\VMware W ...

  6. iOS shell脚本打包

    原文链接:http://www.jianshu.com/p/5abbe0d61cef 参考链接:http://blog.csdn.net/potato512/article/details/52176 ...

  7. IDEA自动编译设置

    ctrl+alt+s: ctrl+shift+alt+/:

  8. StrokesPlus 谷歌搜索结果转https

    StrokesPlus 谷歌搜索结果转https 亲测ie11可用 --清空剪切板 acSetClipboardText('') acSendKeys("^l") --选中地址栏 ...

  9. IOS Https适配摸索

    转:http://www.jianshu.com/p/f312a84a944c https封面 在WWDC 2016开发者大会上,苹果宣布了一个最后期限:到2017年1月1日 App Store中的所 ...

  10. Configure GenieACS

    GenieACS General Config config.json acts as the main configuration file and is stored in /path_to_ge ...