[英]URL Redirect doesn't seem to be working
so I'm working on this project where I need to make a referral module. 所以我正在这个项目上,我需要制作一个推荐模块。 I have to rewrite the URL in such a way, that the page refer_handler.php?refhash=(base64encode(email)) re-writes to /refer/(base64encode(email))
我必须以这样的方式重写URL,即页面Refer_handler.php?refhash =(base64encode(email))重写为/ refer /(base64encode(email))
I have this code for the redirect :- 我有此代码的重定向:-
RewriteRule ^refer/(\d+)$ refer_handler.php?refhash=$1 [L,QSA]
Here's the refer_handler.php 这是Refer_handler.php
<?php
session_start();
include 'dbconnector.php';
include 'inc/inc.functions.php';
include 'dbpdo.php';
if((isset($_SESSION['logged'])) && ($_SESSION['logged']=1))
{
//get the email id from the header
$emailOfTheReferrer = $_REQUEST['refhash']; // we get the refhash from here.
echo base64_decode($emailOfTheReferrer);
////////////////
//Layers -- //
//Check if the refer hash exists (Check if the parent email exists)
}
else
{
header('Location:../index');
}
?>
Problem 问题
The URL re-writes doesn't seems to be working. URL重写似乎不起作用。 When I go to /refer/somerefhash , it says :- Not Found.
当我转到/ refer / somerefhash时,它说:-找不到。 But, if I use the same refhash and then user the URL refer_handler.php?refhash=thehashhere Then everything seems to be working fine.
但是,如果我使用相同的refhash,然后使用URL Refer_handler.php?refhash = thehashhere,那么一切似乎都可以正常工作。
How can I fix this ? 我怎样才能解决这个问题 ?
Thank you. 谢谢。
The problem is (\\d+)
only allows digits. 问题是
(\\d+)
仅允许数字。 And base64
encoded string may contain other characters. 并且
base64
编码的字符串可能包含其他字符。
Try this: 尝试这个:
RewriteRule ^refer/(.+)$ refer_handler.php?refhash=$1 [L,QSA]
This captures 1 or more of any characters instead. 而是捕获任何一个或多个字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.