简体   繁体   English

重定向和htaccess中的php

[英]redirect and php in htaccess

I am facing a weird issue when ugrading to a newer php version (now I have 5.5.9) 升级到较新的php版本时,我遇到一个奇怪的问题(现在我有5.5.9)

my old .htaccess tells me: 我以前的.htaccess告诉我:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$  http://www.example.com/$1 [R=301,L]

direct.php would contain eg: direct.php将包含例如:

<?php 
if ($id == "") {$link = "http://www.example.com";}
if ($id == "10") {$link = "http://google.com";} 
header("Location: $link"); 
exit;
?>

a link like this: 像这样的链接:

http://www.example.com/direct.php?id=10

should direct me to google.com but it wont work anymore and just directs me to www.example.com again, before it worked fine. 应该将我定向到google.com,但它将无法正常工作,只是再次将我定向到www.example.com,然后才能正常工作。 I assume something changed in the variable passing through at php or is it just my htaccess code?! 我假设在php中传递的变量中发生了更改,或者仅仅是我的htaccess代码?

Seems register_globals is the issue. 似乎register_globals是问题。 http://php.net/manual/en/security.globals.php http://php.net/manual/zh/security.globals.php

Add following line at the top: 在顶部添加以下行:

$id = $_GET['id'];

在使用$ id之前添加此代码: $id = $_GET['id']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM