hnmazda 发表于 2008-10-14 10:17:29

.htaccess定义的rewrite规则不起作用

目的:去掉URL中的"index.php"字符串

环境:windows XP
apache 2.2

-----------------------------

httpd.conf


DocumentRoot "E:/website"

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

<Directory "E:/website">


Options Indexes FollowSymLinks

    AllowOverride None

Order allow,deny
    Allow from all

</Directory>

<VirtualHost *:80>
    ServerName www.mydomain.com
    DocumentRoot E:/website/www
</VirtualHost>

LoadModule rewrite_module modules/mod_rewrite.so

-----------------------------
.htaccess


RewriteEngine on
RewriteCond $1 !^(index\.php|public|robots\.txt)
RewriteRule ^(.*)$ index.php/$1

http://www.mydomain.com/index.php/home显示正常


http://www.mydomain.com/home 返回404错误


把$config['index_page']置成空串还是不行,是否apache配置问题?

index.php和.htaccess存储在E:/website/www目录中。

Hex 发表于 2008-10-14 10:46:19

这个就属于 apache 配置问题了,我就不太清楚了,请高手楼下回答,呵呵

沧蓝 发表于 2008-10-14 11:43:17

AllowOverride None
改为
AllowOverride All

hnmazda 发表于 2008-10-14 11:48:49

搞定!谢谢沧蓝
<Directory "E:/website">
Options Indexes FollowSymLinks
    AllowOverride None
Order allow,deny
    Allow from all
</Directory>

AllowOverride None
改为
AllowOverride All
就可以了

xyst0524 发表于 2011-4-28 12:34:30

回复 4# hnmazda


    我改了,为什么我的不可以,能看一下你的根目录以及说一下.htaccess文件的配置和存放的位置吗

xyst0524 发表于 2011-4-28 12:40:16

回复 3# 沧蓝


    我改了,为什么不行呢?
我用的是appserv:

根:
E:\appserv\www

httpd.conf:
<Directory "E:/appserv/www/dilicms_alpha1">
    Options Indexes FollowSymLinks MultiViews ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

/dilicms_alpha1为一个项目的根,在directory容器里去掉dilicms_alpha1也不能打开

.htaccess文件:
RewriteEngine on
RewriteCond $1 !^(index\.php|attachments|robots\.txt|templates|assets|user_guide)   
RewriteRule ^(.*)$ /dilicms_alpha1/index.php/$1

请问哪出问题了???

guanliyang 发表于 2011-4-29 20:38:10

放哪啊,这三个地方。
页: [1]
查看完整版本: .htaccess定义的rewrite规则不起作用