htaccess简单应用
来源:互联网 发布:抢购软件原理 编辑:程序博客网 时间:2024/06/06 03:19
假定项目工程路径为:/var/www/yiitest
域名为:yiitest.com
1.在 /etc/apache2/sites-available 目录中建立文件yiitest,并编辑该文件,内容如下:
3.重启服务器
>>>>>>>>>>>>>>>
应用一:Basic认证模式
在项目工程目录 /var/www/yiitest 下面创建文件 .htaccess ,内容如下:
>>>>>>>>>>>>>>>
应用二:不显示服务器文件列表
在不需要显示文件列表的目录下创建 .htaccess ,内容如下:
域名为:yiitest.com
1.在 /etc/apache2/sites-available 目录中建立文件yiitest,并编辑该文件,内容如下:
<VirtualHost *:80> ServerName yiitest.com ServerAdmin webmaster@yiitest.com DocumentRoot /var/www/yiitest ErrorLog /var/www/yiitest_error.log CustomLog /var/www/yiitest_access.log combined </VirtualHost>2.运行命令,建立链接
a2ensite yiitest此时在/etc/apache2/sites-enabled/目录中发现多了一个yiitest的软链接。
3.重启服务器
/etc/init.d/apache2 restart
>>>>>>>>>>>>>>>
应用一:Basic认证模式
在项目工程目录 /var/www/yiitest 下面创建文件 .htaccess ,内容如下:
<Files ~ "^\.(htaccess|htpasswd)$">deny from all</Files>Options -IndexesAuthUserFile /var/www/yii/.htpasswdAuthGroupFile /dev/nullAuthName "Please enter your ID and password"AuthType Basicrequire valid-userorder deny,allow
创建登录用户:htpasswd -bc /var/www/htaccess/.htpasswd shou test1234※用户名shou、密码test1234
>>>>>>>>>>>>>>>
应用二:不显示服务器文件列表
在不需要显示文件列表的目录下创建 .htaccess ,内容如下:
<Files ~ "^\.(htaccess|htpasswd)$">deny from all</Files>Options -Indexesorder deny,allow
※使用.htaccess的条件(Ubuntu下的配置):
1.mod_rewrite模块开启
less /etc/apache2/mods-available/rewrite.load LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so2.将工作目录下面的AllowOverride None改为AllowOverride All
less /etc/apache2/sites-available/default<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined</VirtualHost>
- htaccess简单应用
- .htaccess是什么?.htaccess几个简单应用
- .htaccess是什么?.htaccess几个简单应用
- .htaccess 文件的应用
- apache .htaccess 的应用
- 简单易用的.htaccess
- .htaccess的重写规则 .htaccess基本语法和应用
- .htaccess的重写规则 .htaccess基本语法和应用
- htaccess
- .htaccess
- htaccess
- htaccess
- .htaccess
- htaccess
- .htaccess
- htaccess
- .htaccess
- .htaccess
- opencv在ubuntu下的安装(2014.11.2更新:读取摄像头的配置)
- rangeOfString的用法
- 模拟cache buffers chains latch实验
- C++访问MySql 转载 还有测
- 怎么在右键菜单添加快速比较的功能
- htaccess简单应用
- TS 中的SDT包
- Oracle 数据库备份和恢复数据库的命令
- 找不到文件 C:\oracle\product\11.2.0\dbhome_1\oc4j\j2ee\oc4j_applications\applications\em.ear
- RAC的并发操作与分布式锁DLM
- Minix 编译内核步骤
- 初涉C++(一)
- jquery 实现上下左右回车键按下 移动文本框焦点
- Apache CXF 架构指南