gpt4 book ai didi

apache - 使用 .htaccess

转载 作者:行者123 更新时间:2023-12-05 01:36:35 26 4
gpt4 key购买 nike

我刚开始学习如何编写 htaccess 。我从 this page 得到以下代码,它将所有内容重定向到 index.php 文件

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/ [L]
</IfModule>

我理解除了 ^$ public/[L](.*) public/[L] 之外的所有行。它们是什么意思。对我来说它看起来像一些常规的压力 :)..我知道 RewriteRule 用于编写重定向规则。但是符号 $ ,(,),., * 等表示什么?
当我将这些行放入 .htaccess 时,出现以下错误

enter image description here

但是当我评论第 4 行时,它正在工作..即.以下代码正在工作

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
#RewriteRule (.*) public/ [L]
</IfModule

那么这里有什么问题呢?

最佳答案

我认为你像 blew 一样在重写循环中:
您将 abc.com/anything 重写为 abc.com/public 并且您正在将/public 重写为/public。
也许你应该指定必须重写哪个 url。 (限制你的请求)像这样:

RewriteEngine on
RewriteRule ^$ public/ [NC,L]
RewriteRule ^index.php(.*)$ public/$1 [NC,L]

重写 index.php?requests 为 public/?requests

关于apache - 使用 .htaccess,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13479928/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com