.htaccess 不工作
RewriteEngine on
RewriteCond $1 !^(index\.php|files|assets|robots\.txt)
RewriteRule ^(.*)$ ./index.php/$1 [L]
该网站托管在最新版本的本地 XAMPP 上。当我加载带有 .htaccess
文件的网站时,它根本不会加载。我收到服务器错误
我做错了什么?
编辑:检查日志文件,这里有一个错误可能有助于指出问题。这是否意味着 mod_rewrite 尚未包含在内?
.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or
defined by a module not included in the server configuration
RewriteEngine on
RewriteCond $1 !^(index\.php|files|assets|robots\.txt)
RewriteRule ^(.*)$ ./index.php/$1 [L]
The website is hosted on the latest version of XAMPP locally. When I load the website with the .htaccess
file in place, it won't load at all. I get a server error
What am I doing wrong?
EDIT: Checked log file, here's an error that might help point the issue out. Does this mean that mod_rewrite has not been included?
.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or
defined by a module not included in the server configuration
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将第一行更改为
Also, Replace your RewriteRule with
If this does not help, 检查您的日志文件。服务器错误通常会向日志文件发出一些信息。
如果这没有帮助,您最好启动您的 RewriteLog 并在此处发布其中的一些内容。
Change your first line to
Also, replace your RewriteRule with
If this doesn't help, check your log file. Server errors will normally issue something to the log file.
If that doesn't help, you'd best crank up your RewriteLog and post some of that here.
正如已经指出的那样,第一行应该更改:
但是您确实应该仅在请求尚不存在时重定向请求(否则所有静态请求,例如图像和 css,也将通过index.php)
The first line, as has been pointed out, should be changed :
but you really ought to redirect requests only if they do not already exists (otherwise all your static requests, eg images and css, would go through index.php as well)
您确定在 XAMPP 中启用了 mod_rewrite 吗?快速谷歌搜索显示(至少在旧版本的 XAMPP 中),默认情况下未启用 mod_rewrite。也许这是你的问题?
Have you made sure to enable mod_rewrite in XAMPP? A quick googling revealed that (at least in older versions of XAMPP), mod_rewrite was not enabled by default. Maybe this is your issue?