问题描述
一切都很完美。看起来它明白我想要什么,但随后我无法理解的事情开始发生。我的 .htaccess 看起来像这样:
重写引擎开启
RewriteBase "/"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^contacts/edit(new|existing)$ /index.PHP?route=contacts/edit$1 [NC,L,QSA]
日志中第一个相关的行是 ->
[Wed Apr 07 14:23:41.495232 2021] [rewrite:trace2] [pid 2302] mod_rewrite.c(483): [client ::1:13883] ::1 - - [localhost/sid#209cc4c8] [rid#23090058/initial] [perdir /path/to/document/root/] 重写 'contacts/editNew' -> '/index.PHP?route=contacts/editNew',referer: http://localhost/>
- 注释:它查看请求 URI 并尝试将其替换为“index.PHP?route=...”
第 2 行 ->
[Wed Apr 07 14:23:41.495256 2021] [rewrite:trace3] [pid 2302] mod_rewrite.c(483): [client ::1:13883] ::1 - - [localhost/sid#209cc4c8] [rid#23090058/initial] 拆分 uri=/index.PHP?route=contacts/editNew -> uri=/index.PHP,args=route=contacts/editNew,referer: http://localhost/
- 注释:它尝试将 uri 拆分为 URI 和参数。
第 3 行 ->
[Wed Apr 07 14:23:41.495283 2021] [rewrite:trace2] [pid 2302] mod_rewrite.c(483): [client ::1:13883] ::1 - - [localhost/sid#209cc4c8] [rid#23090058/initial] [perdir /document/root/path/] 试图用 / 替换前缀 /path/to/document/root/,引用:http://localhost/
- 注释:mod_rewrite 只是将 DOCUMENT_ROOT 路径转换为“/”。
第 4 行 ->
[Wed Apr 07 14:23:41.495311 2021] [rewrite:trace2] [pid 2302] mod_rewrite.c(483): [client ::1:13883] ::1 - - [localhost/sid#209cc4c8] [rid#23090058/initial] [perdir /path/to/document/root/] 试图用上下文前缀替换上下文 docroot /path/to/document/root,引用:http://localhost/
第 5 行 ->
[Wed Apr 07 14:23:41.495334 2021] [rewrite:trace1] [pid 2302] mod_rewrite.c(483): [client ::1:13883] ::1 - - [localhost/sid#209cc4c8] [rid#23090058/initial] [perdir /path/to/document/root/] 使用 /index.PHP [INTERNAL REDIRECT] 的内部重定向,引用:http://localhost/
第 6 行 ->
[Wed Apr 07 14:23:41.495834 2021] [rewrite:trace3] [pid 2302] mod_rewrite.c(483): [client ::1:13883] ::1 - - [localhost/sid#209cc4c8] [rid#23091b18/initial/redir#1] [perdir /path/to/document/root/] 去掉 per-dir 前缀:/path/to/document/root/index.PHP -> index.PHP,referer:http ://本地主机/
第 7 行 ->
[Wed Apr 07 14:23:41.495900 2021] [rewrite:trace3] [pid 2302] mod_rewrite.c(483): [client ::1:13883] ::1 r- - [localhost/sid#209cc4c8 ][rid#23091b18/initial/redir#1] [perdir /path/to/document/root/] 将模式 '^contacts/edit(new|existing)$' 应用到 uri 'index.PHP',引用:http: //本地主机/
- 评论:这就是让我感到困惑的地方。 '^contacts/edit(edit|existing)$' 应用于 uri 'index.PHP',但不适用于 'index.PHP?route=contacts/edit$1',我相信这是我在我的第二个重写规则。那么,为什么没有发生这种情况??
最后,我不知道为什么会发生这种情况,整个 URL 被转换为“http://contacts/editnew”!甚至 localhost 也被删除了。
如果您能帮我解决这个问题,我将不胜感激。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)