A. 设置godaddy 关于.htaccess 文件的设置 我想把网站首页打开优先级设置为 index.php 请问怎么操作
DirectoryIndex index.php
这样
B. 如何利用.htaccess文件对PHP网站或文件进行伪静态处理
利用.htaccess文件对PHP网站进行伪静态处理要考虑两点:
一.服务器支持伪静态,比如Apache要开启mod_rewrite模块支持
二.利用.htaccess完成伪静态需要根据不同的网站系统进行不同的设置,以下是一些常见系统的.htaccess设定:
01.wordpress:
# BEGIN WordPress
<IfMole mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfMole>
02.Phpwind
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
RewriteRule ^(.*)simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2
03.Discuz
RewriteEngine On
# Rewrite 系统规则请勿修改
RewriteRule ^archiver/((fid|tid)-[0-9]+\.html)$ archiver/index.php?$1
RewriteRule ^forum-([0-9]+)-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ viewthread.php?tid=$1&extra=page\%3D$3&page=$2
RewriteRule ^space-(username|uid)-(.+)\.html$ space.php?$1=$2
RewriteRule ^tag-(.+)\.html$ tag.php?name=$1
04.ecshop
RewriteEngine On
# direct one-word access
RewriteRule ^index\.html$ index\.php [L]
RewriteRule ^category$ index\.php [L]
# access any object by its numeric identifier
RewriteRule ^feed-c([0-9]+)\.xml$ feed\.php\?cat=$1 [L]
RewriteRule ^feed-b([0-9]+)\.xml$ feed\.php\?brand=$1 [L]
RewriteRule ^feed\.xml$ feed\.php [L]
RewriteRule ^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ category\.php\?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 [QSA,L]
RewriteRule ^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$ category\.php\?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5 [QSA,L]
RewriteRule ^category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ category\.php\?id=$1&brand=$2&page=$3&sort=$4&order=$5 [QSA,L]
RewriteRule ^category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$ category\.php\?id=$1&brand=$2&page=$3 [QSA,L]
RewriteRule ^category-([0-9]+)-b([0-9]+)(.*)\.html$ category\.php\?id=$1&brand=$2 [QSA,L]
RewriteRule ^category-([0-9]+)(.*)\.html$ category\.php\?id=$1 [QSA,L]
RewriteRule ^goods-([0-9]+)(.*)\.html$ goods\.php\?id=$1 [QSA,L]
RewriteRule ^article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ article_cat\.php\?id=$1&page=$2&sort=$3&order=$4 [QSA,L]
RewriteRule ^article_cat-([0-9]+)-([0-9]+)(.*)\.html$ article_cat\.php\?id=$1&page=$2 [QSA,L]
RewriteRule ^article_cat-([0-9]+)(.*)\.html$ article_cat\.php\?id=$1 [QSA,L]
RewriteRule ^article-([0-9]+)(.*)\.html$ article\.php\?id=$1 [QSA,L]
RewriteRule ^brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html brand\.php\?id=$1&cat=$2&page=$3&sort=$4&order=$5 [QSA,L]
RewriteRule ^brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html brand\.php\?id=$1&cat=$2&page=$3 [QSA,L]
RewriteRule ^brand-([0-9]+)-c([0-9]+)(.*)\.html brand\.php\?id=$1&cat=$2 [QSA,L]
RewriteRule ^brand-([0-9]+)(.*)\.html brand\.php\?id=$1 [QSA,L]
RewriteRule ^tag-(.*)\.html search\.php\?keywords=$1 [QSA,L]
RewriteRule ^snatch-([0-9]+)\.html$ snatch\.php\?id=$1 [QSA,L]
RewriteRule ^group_buy-([0-9]+)\.html$ group_buy\.php\?act=view&id=$1 [QSA,L]
RewriteRule ^auction-([0-9]+)\.html$ auction\.php\?act=view&id=$1 [QSA,L]
05.phpcms
RewriteEngine On
RewriteRule ^(.*)content-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/index\.php\?m=content&c=index&a=show&catid=$2&id=
$3&page=$4
RewriteRule ^(.*)show-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/index\.php\?m=content&c=index&a=show&catid=$2&id=
$3&page=$4
RewriteRule ^(.*)list-([0-9]+)-([0-9]+).html$ $1/index\.php\?m=content&c=index&a=lists&catid=$2&page=$3
C. 加了.htaccess文件为什么仍不能去掉index.php
1. 在httpd.conf中,将 所有 AllowOverride None 改为 AllowOverride All 好像共有三处吧,然后重启apache2. 在.htaccess文件中,是这样的配置:RewriteEngine onRewriteCond $1 !^(index\.php|robots|stafile|upload|\.txt)RewriteRule ^(.*)$ /index.php/$1 [L]如果你是直接在根目录配置的,则以上就可以了;假如你的项目在根目录底下一层,则 RewriteRule ^(.*)$ /index.php/$1 [L] 得变为 RewriteRule ^(.*)$ /项目文件夹名/index.php/$1 [L]以上两步已经可以去掉 index.php了,假如项目中的路径,为了去掉index.php,还需要第 3 步 操作,因为第 3 步 是影响到 site_url();这个函数的。3. 将 config.php中的 $config['index_page'] = 'index.php'; 改为 $config['index_page'] = '';
D. 如何利用.htaccess文件对PHP网站或文件进行伪静态处理
一、检查服务器是否支持伪静态处理:
必须要空间支持 Rewrite 以及对站点目录中有 .htaccess
的文件解析,才有效.找到apache安装目录下的httpd.cof文件,去掉LoadMole rewrite_mole
moles/mod_rewrite.so前面的#(大概在154行,我的默认是开启)
二、在httpd.cof中查找以下部分:
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
改为:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
如果没有,手动添加。(PS:LZ试过,在最近的新版本的Apache上即使没有这个,.htaccess照样生效。但是不同服务器及版本的原因,建议加上)
三、重启apache服务器,添加.htaccess文件
建立.htaccess文件的方式:
1、保存文件的时候将文档保存成名为“***.txt”,再将其上传到服务器上,之后直接使用FTP软件来重命名为“.htaccess”。(适合windows)
2、保存文件的时候选择文件—>另存为,保存类型选所有文件,然后文件名输入.htaccess 。(适合windows)
3、直接在你的Unix或Linux虚拟主机上建立。
4、先用记事本编写好,随便保存为一个什么文件名,然后打开“命令提示符”(CMD),然后再用重命名命令(rename),例如:rename c:\htaccess.txt .htaccess
请注意: .htaccess必须,保存为ANSI 格式,以ASCII模式上传,最好将其权限设置为644。
一般我们将.htaccess文件放置在网站的根目录,控制所在目录及所有子目录,当然也可以放在网站的任何一个子目录下,但如果放置在子目录中,子目录中的指令会覆盖更高级目录或者主服务器配置文件中的指令。
在博客收录集(http://www.ido321.com/1112.html)为例,本地.htaccess文件如下:
#rewriteengine为重写引擎开关on为开启off为关闭
RewriteEngine On
RewriteRule ^index\.html$ index.php
RewriteRule ^webmore\.html$ webmore.php
以index.html代替index.php webmore.html代替webmore.php。
.htaccess支持正则表达式,例如:
原始 news/detail.php?id=2 伪静态 news/detail_2.html
RewriteRule ^news/detail_([0-9]{1,})\.html$ news/detail.php?id=$1
E. index.php和.htaccess是根目录的文件么我给删了,怎么办
htaccess文件删了,可以重新创建个上传就行了,index.php是你程序的首页吗?这个删了你网上还能正常访问吗
F. thinkPHP无法隐藏index.php,设置了htaccess和Apache
thinkphp取消index.php的话需要两方面改动,一是apache开启rewrite模块或iis安装rewrite组件;另一方面是在网站下放入重写规则文件,apache对应.htaccess,iis对应httpd.ini
G. htaccess如何自定义php后缀
首先,apache配置下,有一个配置表示默认将后缀为.php的文件进行解析,当然你可以进行配置,改成其它后缀的。不过你既然有.htaccess文件了,为什么要加那个后缀呢?一般里面的规则如下
<IfMole mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfMole>
定义好这个规则后就不用加text.php了。只不过,apache一般默认解析的是index.php,所以我提供的规则也是默认指向index.php的。
H. ThinkPHP实现伪静态如何去掉目录中的index.php
Myapp是我的项目文件名,默认的访问地址是上面这样的。为了使URL更加简介友好,现在要去掉中间的index.php,方法如下:
1。确认httpd.conf配置文件中加载了mod_rewrite.so 模块,加载的方法是去掉mod_rewrite.so前面的注释#号
2。讲httpd.conf中的Allowoverride None 将None改为All
3。打开对应的项目配置文件,我的项目配置文件是Myapp/Conf/config.php ,在这个配置文件数组中增加一行,‘URL_MODEL’=>2
4。在项目的根目录下面建立一个.htaccess文件,里面写入下面的内容:
<IfMole rewrite_mole>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfMole>
如果你的服务器支持rewrite,现在就可以通过http://localhost/Myapp/Index/index/访问Index模块下面的index操作。
I. index.php怎么解决
因为你后台没有设置默认主页文件第一个为index.php
去控制面板设置下顺序就可以了。
J. url重写,在.htaccess里怎么把index.php改掉
RewriteEngine On
RewriteBase /
RewriteRule ^localhost/[email protected]$ localhost/[email protected]