.htaccess不能在xampp (windows 7)上工作


.htaccess doesn't work on xampp (windows 7)

我现在正在设置我的.htaccess文件使用友好的url (手动)。但是,当我去到url服务器显示我错误404

RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  
Rewriterule ^register$ register.php 

我真的很确定mod_rewrite是启用的,因为我看到它时使用phpinfo()

即使mod-rewrite是启用的,默认情况下.htaccess文件不启用

屏住呼吸

  • 打开示例控制面板
  • 停止Apache
  • 点击Apache行上的Config按钮,选择httpd.conf
  • 在该文件中,搜索xampp/htdocs">
  • 稍微低一点,你可能会看到这样一条线:# AllowOverride All。删除#,这是一个注释
  • 或者,搜索AllowOverride All,确保它在正确的部分,并删除注释#
  • 保存文件
  • 重启Apache,祈祷,交叉手指,屏住呼吸

这个清单可能是旧的,但仍然相关,因此为了使其更安全,最好添加几行。

Deny from all
Allow from 127.0.0.1 ::1 localhost
Allow from .htaccess

另外,作为旁注。htaccess文件会减慢服务器的速度,因此最好参考xampp文档了解最佳实践。

希望能有所帮助。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

首先,我们在项目的根目录下创建一个.htaccess文件,没有任何扩展名。将代码添加到文件中删除index。php Application/config/config。php

检查httpd.conf标签,查看此属性

AllowOverride All