.htaccess 不工作

发布于 2024-08-11 05:00:23 字数 498 浏览 3 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

·深蓝 2024-08-18 05:00:23

将第一行更改为

RewriteEngine On

Also, Replace your RewriteRule with

RewriteRule ^(.*)$ index.php/$1 [L]

If this does not help, 检查您的日志文件。服务器错误通常会向日志文件发出一些信息。

如果这没有帮助,您最好启动您的 RewriteLog 并在此处发布其中的一些内容。

Change your first line to

RewriteEngine On

Also, replace your RewriteRule with

RewriteRule ^(.*)$ index.php/$1 [L]

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.

很酷又爱笑 2024-08-18 05:00:23

正如已经指出的那样,第一行应该更改:

RewriteEngine On

但是您确实应该仅在请求尚不存在时重定向请求(否则所有静态请求,例如图像和 css,也将通过index.php)

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

The first line, as has been pointed out, should be changed :

RewriteEngine On

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)

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
红衣飘飘貌似仙 2024-08-18 05:00:23

您确定在 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文