.htaccess整体伪静态规则和目录排除

最近在.htaccess的伪静态中遇到一些问题,下面记录一下遇到的疑问和解决的方法:

1..htaccess的伪静态规则写法

# 根目录文件夹访问伪静态到cunfang1下

RewriteRule ^([a-z0-9A-Z_\-]+)(/)?$ /cunfang1/$1/ [L]

上面的规则可以将所有针对网站根目录下文件夹的访问,伪静态到cunfang1下面的对应文件夹。

2.排除某些目录,让第一条规则无法对其产生作用,比如网站根目录下的/DATA、/images等等。

# 根目录文件夹访问排除规则

RewriteCond $1 !^(DATA|images|otherThings)

将上述代码放置在第一段规则之前即可实现指定目录排除的功能。

主题测试文章,只做测试使用。发布者:Yusky,转转请注明出处:https://yusky.me/htaccess%e6%95%b4%e4%bd%93%e4%bc%aa%e9%9d%99%e6%80%81%e8%a7%84%e5%88%99%e5%92%8c%e7%9b%ae%e5%bd%95%e6%8e%92%e9%99%a4.html

(0)
Yusky的头像Yusky
上一篇 2016 年 3 月 8 日
下一篇 2016 年 4 月 24 日

相关推荐

  • httpd: Could not reliably determine the server’s fully qualified domain name, using server.abc.com for ServerName

    问题 Stopping httpd: [ OK ] Starting httpd: httpd: Could not reliably determine the server’s fully qualified domain name, using server.abc.com for ServerName 原因 httpd.conf 文件未配置Serve…

    Linux 2015 年 12 月 7 日
    2.1K00
  • 清理Linux下的大文件

    查找大文件 find /dir -size +100M -exec ls -lh {} \; 如果要清空一些文本文件类的东西,可以使用 echo “” > /www/xxx.log 如果想直接删除大于50M的文件,使用命令 find /var/mail/ -size +50M -exec rm {} \; 如果想排序文件夹和文件,可以使用 du -s …

    Linux 2014 年 3 月 30 日
    6.1K30
  • Apache http自动跳转到https的几种方法

    方法1 RewriteEngine On RewriteBase / RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://yusky.me/$1 [R=301,L] #这样跳转的好处是独立IP主机也支持,访问ip能自动跳转到https 方法二 RewriteEngine on RewriteCon…

    Linux 2015 年 12 月 3 日
    5.6K00
  • 修改DirectAdmin默认WebMail为Roundcube

    Directadmin安装完成以后,默认的Webmail程序使用的是SquirrelMail,足够精简和小巧,但是,界面也太简陋了吧,而且由于编码问题,似乎中文很容易出现乱码。如何把把默认的网页邮件更改为界面更友好的RoundCube? 去官网上搜索了一下,找到解决方法: 修改directadmin.conf vi /usr/local/directadmi…

    Linux 2014 年 5 月 30 日
    4.2K00
  • [CentOS]压缩+解压+打包命令大全

    .tar 解包:tar xvf FileName.tar 打包:tar cvf FileName.tar DirName (注:tar是打包,不是压缩!) ——————————————— .gz 解压1:gunzip FileName.gz 解压2:gzip -d FileName.gz 压缩:gzip FileName .tar.gz 和 .tgz 解压:…

    2013 年 10 月 25 日
    8.2K10

回复 guest

您的电子邮箱地址不会被公开。 必填项已用 * 标注

评论列表(5条)

  • 殁漂遥的头像
    殁漂遥 2016 年 4 月 22 日 上午 8:48

    膜拜了,当然了,我也看不到明白

  • guest的头像
    guest 2016 年 4 月 18 日 下午 8:01

    EV证书怎么搞的?

  • 米粒博客的头像
    米粒博客 2016 年 4 月 8 日 下午 8:47

    很实用 谢谢分享

  • 李阳博客的头像
    李阳博客 2016 年 4 月 7 日 下午 5:55

    过来学习一下

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:[email protected]

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
自6.2开始主题新增页头通知功能,购买用户可免费升级到最新版体验