Php 加密 url
Php encrypt url
我需要你的帮助,我正在使用 codeigniter php 进行 url 加密,
我使用默认的codeigniter加密class,不改变配置,
但是当我加密时 url 显示错误
"Object Not found , the request url was not found on this server"
我加密 url
的方式
$e_email_app = $this->encryption->encrypt($email_app);
$e_email_app = urlencode($e_email_app);
$newurl = base_url()."job_applicant/fill_data/".$e_email_app;
我已经在 http.conf 上启用了 apache mod_rewrite,我正在使用这样的虚拟主机
<VirtualHost *:83>
ServerAdmin 192.168.77.204:83
DocumentRoot "C:/xampp/htdocs/Vacancy/public"
<Directory "C:/xampp/htdocs/Vacancy/public">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
我的 .htacess 是
重写引擎开启
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond !^(index\.php|css|images|robots\.txt)
RewriteRule ^(.*)$ ./index.php/ [L]
我该怎么办?更改加密算法?
请帮忙..
@George Sazanovich:谢谢你的建议,但 codeigniter 没问题,因为有时失败有时成功,而且我已经设置了加密密钥
也许是 apache url 配置?
似乎您正在尝试使用保留名称 CI_Controller
$newurl = base_url()."controller/method/".$e_email_app;
或者这是针对问题编辑的,您有控制器和方法的真实名称吗?另外,请检查加密是否成功:
$email_app = "test string";
$newurl = base_url("controller/method/".urlencode($this->encryption->encode($email_app)));
$decoded = $this->encryption->decode(urldecode($newurl));
echo $decoded; // must be "test string" after Your base_url()
还有一个:要使用加密库,您必须在配置文件中设置加密密钥(application/config/config.php
-> $config['encryption_key']
)。
如果一切正常,只有一个原因会破坏您的脚本:apache/CodeIgniter 修剪您的 URL 的一部分。检查它的最简单方法 - 查看控制器收到的内容:
/* controller (for example mymail) defenition here */
// here's your http://domain.com/mymail/mycheck/
public function mycheck($param){
var_dump($param);
}
此外,base_url()
接受参数,所以
base_url().'test/param';
等于
base_url('test/param');
编辑
我检查过你的字符串,在 GET 中 post "%2F
" 似乎是非法的。因此,您的编码字符串中的非法字符存在问题(您可以尝试仅使用 %2F 作为您的编码字符串,它会破坏应用程序)。
更新
%2F 将被浏览器 urldecoded 为 /
(例如 %20 </code>(空白)。所以浏览器认为您的请求是 <code>/controller/method/_encoded_string_/_part_after_%2F_
我需要你的帮助,我正在使用 codeigniter php 进行 url 加密,
我使用默认的codeigniter加密class,不改变配置,
但是当我加密时 url 显示错误
"Object Not found , the request url was not found on this server"
我加密 url
的方式$e_email_app = $this->encryption->encrypt($email_app);
$e_email_app = urlencode($e_email_app);
$newurl = base_url()."job_applicant/fill_data/".$e_email_app;
我已经在 http.conf 上启用了 apache mod_rewrite,我正在使用这样的虚拟主机
<VirtualHost *:83>
ServerAdmin 192.168.77.204:83
DocumentRoot "C:/xampp/htdocs/Vacancy/public"
<Directory "C:/xampp/htdocs/Vacancy/public">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
我的 .htacess 是
重写引擎开启
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond !^(index\.php|css|images|robots\.txt)
RewriteRule ^(.*)$ ./index.php/ [L]
我该怎么办?更改加密算法? 请帮忙..
@George Sazanovich:谢谢你的建议,但 codeigniter 没问题,因为有时失败有时成功,而且我已经设置了加密密钥
也许是 apache url 配置?
似乎您正在尝试使用保留名称 CI_Controller
$newurl = base_url()."controller/method/".$e_email_app;
或者这是针对问题编辑的,您有控制器和方法的真实名称吗?另外,请检查加密是否成功:
$email_app = "test string";
$newurl = base_url("controller/method/".urlencode($this->encryption->encode($email_app)));
$decoded = $this->encryption->decode(urldecode($newurl));
echo $decoded; // must be "test string" after Your base_url()
还有一个:要使用加密库,您必须在配置文件中设置加密密钥(application/config/config.php
-> $config['encryption_key']
)。
如果一切正常,只有一个原因会破坏您的脚本:apache/CodeIgniter 修剪您的 URL 的一部分。检查它的最简单方法 - 查看控制器收到的内容:
/* controller (for example mymail) defenition here */
// here's your http://domain.com/mymail/mycheck/
public function mycheck($param){
var_dump($param);
}
此外,base_url()
接受参数,所以
base_url().'test/param';
等于
base_url('test/param');
编辑
我检查过你的字符串,在 GET 中 post "%2F
" 似乎是非法的。因此,您的编码字符串中的非法字符存在问题(您可以尝试仅使用 %2F 作为您的编码字符串,它会破坏应用程序)。
更新
%2F 将被浏览器 urldecoded 为 /
(例如 %20 </code>(空白)。所以浏览器认为您的请求是 <code>/controller/method/_encoded_string_/_part_after_%2F_