htaccess 文件不适用于特殊字符
htaccess file dont work with special character
我从 codeigniter 复制了我的 .htaccess
,
我有一个页面,它应该有一个 href
<a href="/notification/<?= rawurlencode(urlencode($tab['href']))?>">
如果我从 href 中删除特殊字符,htaccess 将正确获取请求
htaccess 文件:
# Disable directory browsing
Options All -Indexes
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Rewrite "www.example.com -> example.com"
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to the front controller, index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\s\S]*)$ index.php/ [L,NC,QSA]
# Ensure Authorization header is passed along
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
ServerSignature Off
使用 codeigniter,您不应传递 URL 带有特殊字符的段。这些过滤器是出于安全原因而存在的。相反,将它们作为 GET 变量传递。
<a href="/notification?tab=<?=rawurlencode(urlencode($tab['href']))?>">
.. 并在您的控制器中
class Notification extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
$tab = $this->input->get('tab');
}
我从 codeigniter 复制了我的 .htaccess
,
我有一个页面,它应该有一个 href
<a href="/notification/<?= rawurlencode(urlencode($tab['href']))?>">
如果我从 href 中删除特殊字符,htaccess 将正确获取请求
htaccess 文件:
# Disable directory browsing
Options All -Indexes
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Rewrite "www.example.com -> example.com"
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to the front controller, index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\s\S]*)$ index.php/ [L,NC,QSA]
# Ensure Authorization header is passed along
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
ServerSignature Off
使用 codeigniter,您不应传递 URL 带有特殊字符的段。这些过滤器是出于安全原因而存在的。相反,将它们作为 GET 变量传递。
<a href="/notification?tab=<?=rawurlencode(urlencode($tab['href']))?>">
.. 并在您的控制器中
class Notification extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
$tab = $this->input->get('tab');
}