.htaccess mod_rewrite 刚刚破坏了该网站

发布于 2024-08-24 10:46:50 字数 1215 浏览 0 评论 0原文

在以下 .htaccess 文件中...


RewriteEngine on
RewriteCond %{HTTP_HOST} ^getpearson.com$
RewriteRule ^/?$ "http\:\/\/www\.getpearson\.com" [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^redesign_03012010/mock-up/([^/]+)/([^/]+)$ /redesign_03012010/mock-up/index.php?page=$1§ion=$2 [PT]
RewriteRule ^redesign_03012010/mock-up/([^/]+)$ /redesign_03012010/mock-up/index.php?page=$1 [PT]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)$ /index.php?test=1&page=$1§ion=$2
RewriteRule ^([^/]+)$ /index.php?test=1&page=$1 [L]

我删除了修改后的最后 3 行:


RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)$ /index.php?test=1&page=$1§ion=$2
RewriteRule ^([^/]+)$ /index.php?test=1&page=$1 [L]

to:


RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)$ /index.php?page=$1§ion=$2
RewriteRule ^([^/]+)$ /index.php?page=$1 [L]

...因此仅删除了 'test=1&' url 变量,现在它没有了...这个疯狂的 htaccess 行话的逻辑是什么?这让我很困惑。无论如何,我做了一个 php 解决方法,直到我能解决这个问题,所以不用担心,但请帮忙!谢谢!

in the following .htaccess file...


RewriteEngine on
RewriteCond %{HTTP_HOST} ^getpearson.com$
RewriteRule ^/?$ "http\:\/\/www\.getpearson\.com" [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^redesign_03012010/mock-up/([^/]+)/([^/]+)$ /redesign_03012010/mock-up/index.php?page=$1§ion=$2 [PT]
RewriteRule ^redesign_03012010/mock-up/([^/]+)$ /redesign_03012010/mock-up/index.php?page=$1 [PT]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)$ /index.php?test=1&page=$1§ion=$2
RewriteRule ^([^/]+)$ /index.php?test=1&page=$1 [L]

i removed modified the last 3 lines from:


RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)$ /index.php?test=1&page=$1§ion=$2
RewriteRule ^([^/]+)$ /index.php?test=1&page=$1 [L]

to:


RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)$ /index.php?page=$1§ion=$2
RewriteRule ^([^/]+)$ /index.php?page=$1 [L]

...hence only removing the 'test=1&' url variable, and now it no werkie... what is the logic to this crazy htaccess lingo? it stumps me. anyhow, i did a php work-around until i can figure this out, so no worries, but please help! thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

静谧 2024-08-31 10:46:50

“no werkie”有点模糊...您对规则所做的编辑似乎不错。也许index.php页面期望“test”变量存在,如果不存在就会崩溃?

不要从查询字符串中删除“test”变量,而是尝试将“test=1”更改为“test=0”。

"no werkie" is a little vague... The edit you made to the rules seems fine. Maybe the index.php page is expecting the "test" variable to be present and will crash if it isn't?

Instead of removing the "test" variable from the query string, try just changing "test=1" to "test=0" instead.

一张白纸 2024-08-31 10:46:50

卢卡斯,
我认为你的最后两条规则在模式之前缺少 / 。并且还要去掉[PT],在这种情况下这是不合适的。

RewriteRule ^/([^/]+)/([^/]+)$ /index.php?test=1&page=$1§ion=$2
RewriteRule ^/([^/]+)$ /index.php?test=1&page=$1 [L]

汤姆

Lucas,
I think you're last two rules are missing a / before the pattern. And also take out [PT] it's not appropriate in this case.

RewriteRule ^/([^/]+)/([^/]+)$ /index.php?test=1&page=$1§ion=$2
RewriteRule ^/([^/]+)$ /index.php?test=1&page=$1 [L]

Tom

被翻牌 2024-08-31 10:46:50

听起来像是 index.php 文件中的问题,而不是 .htaccess 中的问题。当您在没有 test=1 的情况下直接访问 index.php 而不是通过重写的 URL 访问时会发生什么?我怀疑它被配置为在这种情况下抛出 500 错误。

Sounds like a problem in your index.php file, not .htaccess. What happens when you access index.php without test=1 directly instead of via the rewritten URL? I suspect it's configured to throw a 500 error in that situation.

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