.htaccess mod_rewrite 刚刚破坏了该网站
在以下 .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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
“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.
卢卡斯,
我认为你的最后两条规则在模式之前缺少 / 。并且还要去掉[PT],在这种情况下这是不合适的。
汤姆
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.
Tom
听起来像是
index.php
文件中的问题,而不是.htaccess
中的问题。当您在没有test=1
的情况下直接访问index.php
而不是通过重写的 URL 访问时会发生什么?我怀疑它被配置为在这种情况下抛出 500 错误。Sounds like a problem in your
index.php
file, not.htaccess
. What happens when you accessindex.php
withouttest=1
directly instead of via the rewritten URL? I suspect it's configured to throw a 500 error in that situation.