开发者

.htaccess mod_rewrite just broke the site

开发者 https://www.devze.com 2022-12-22 07:56 出处:网络
in the following .htaccess file... RewriteEngine on RewriteCond %{HTTP_HOST} ^getpearson.com$ RewriteRule ^/?$ \"http\\:\\/\\/www\\.getpearson\\.com\" [R=301,L]

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=$开发者_JS百科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!


"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.


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&section=$2
RewriteRule ^/([^/]+)$ /index.php?test=1&page=$1 [L]

Tom


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消