Php .htaccess重写;但需要变量

Php .htaccess重写;但需要变量,php,.htaccess,mod-rewrite,Php,.htaccess,Mod Rewrite,你好,斯塔克尔斯, 我目前的HTACCESS文件有问题。它需要重写一个Url,确实如此,但我仍然需要一个变量来传递 RewriteRule ^ref/(.*)$ /quickregister/start.php?ref=$1 使用的链接是example.com/ref/value,但是,重写后,没有可识别的变量,但我需要ref变量的值 有办法做到这一点吗?此外,我希望仍然能够获得if(isset($\u get['ref']){工作。这是我的标准.htaccess文件,我用于所有重写网站 ##

你好,斯塔克尔斯,

我目前的HTACCESS文件有问题。它需要重写一个Url,确实如此,但我仍然需要一个变量来传递

RewriteRule ^ref/(.*)$ /quickregister/start.php?ref=$1
使用的链接是
example.com/ref/value
,但是,重写后,没有可识别的变量,但我需要ref变量的值


有办法做到这一点吗?此外,我希望仍然能够获得
if(isset($\u get['ref']){
工作。

这是我的标准.htaccess文件,我用于所有重写网站

## No directory listings
IndexIgnore *

## Can be commented out if causes errors, see notes above.
Options +FollowSymlinks
Options -Indexes

## Mod_rewrite in use.

RewriteEngine On

# Block out any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL.
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
## End - Rewrite rules to block out some common exploits.

## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
## End - Custom redirects


RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
##没有目录列表
IndexIgnore*
##如果导致错误,可以注释掉,请参见上面的注释。
选项+FollowSymlinks
选项-索引
##Mod_正在使用中重写。
重新启动发动机
#阻止任何试图在URL中对数据进行base64_编码的脚本。
RewriteCond%{QUERY\u STRING}base64\u encode[^(]*\([^)]*\)[或]
#阻止在URL中包含标记的任何脚本。
重写cond%{QUERY_STRING}(|%3E)[NC,或]
#阻止任何试图通过URL设置PHP全局变量的脚本。
重写条件%{QUERY\u STRING}全局(|\[|\%[0-9A-Z]{0,2})[或]
#阻止任何试图通过URL修改_请求变量的脚本。
重写条件%{QUERY\u STRING}\u请求(|\[|\%[0-9A-Z]{0,2})
#返回403禁止标题并显示根主页的内容
重写规则。*index.php[F]
#
##结束-重写规则以阻止一些常见的漏洞攻击。
##开始-自定义重定向
#
#如果需要重定向某些页面,或将规范非www设置为
#www重定向(反之亦然),将代码放在这里
#重定向使用正确的重写规则语法和[R=301,L]标志。
#
##结束-自定义重定向
重写规则。*-[E=HTTP\U授权:%{HTTP:AUTHORIZATION}]
重写cond%{REQUEST_URI}!^/index\.php
重写cond%{REQUEST_FILENAME}!-f
重写cond%{REQUEST_FILENAME}!-d
重写规则。*index.php[L]
使用此文件,URL中的所有内容(如果它不是有效的目录或文件)都将被忽略并路由到站点根目录中的index.php。然后,我使用
$\u SERVER['REQUEST\u URI']
将其作为单个参数访问,我可以使用
explode(“/”,$\u SERVER['REQUEST\u URI'])对其进行分解
,这将为我提供一个从每个值的索引0开始的数组。使用此脚本,我仍然能够访问$\u GET变量,只要在URI末尾使用了约定
?var\u name=value


这已经过测试,适用于Apache、PHP5,适用于基于debian的linux操作系统以及Apache的Windows安装。

这是我的标准.htaccess文件,我用于所有重写网站

## No directory listings
IndexIgnore *

## Can be commented out if causes errors, see notes above.
Options +FollowSymlinks
Options -Indexes

## Mod_rewrite in use.

RewriteEngine On

# Block out any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL.
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
## End - Rewrite rules to block out some common exploits.

## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
## End - Custom redirects


RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
##没有目录列表
IndexIgnore*
##如果导致错误,可以注释掉,请参见上面的注释。
选项+FollowSymlinks
选项-索引
##Mod_正在使用中重写。
重新启动发动机
#阻止任何试图在URL中对数据进行base64_编码的脚本。
RewriteCond%{QUERY\u STRING}base64\u encode[^(]*\([^)]*\)[或]
#阻止在URL中包含标记的任何脚本。
重写cond%{QUERY_STRING}(|%3E)[NC,或]
#阻止任何试图通过URL设置PHP全局变量的脚本。
重写条件%{QUERY\u STRING}全局(|\[|\%[0-9A-Z]{0,2})[或]
#阻止任何试图通过URL修改_请求变量的脚本。
重写条件%{QUERY\u STRING}\u请求(|\[|\%[0-9A-Z]{0,2})
#返回403禁止标题并显示根主页的内容
重写规则。*index.php[F]
#
##结束-重写规则以阻止一些常见的漏洞攻击。
##开始-自定义重定向
#
#如果需要重定向某些页面,或将规范非www设置为
#www重定向(反之亦然),将代码放在这里
#重定向使用正确的重写规则语法和[R=301,L]标志。
#
##结束-自定义重定向
重写规则。*-[E=HTTP\U授权:%{HTTP:AUTHORIZATION}]
重写cond%{REQUEST_URI}!^/index\.php
重写cond%{REQUEST_FILENAME}!-f
重写cond%{REQUEST_FILENAME}!-d
重写规则。*index.php[L]
使用此文件,URL中的所有内容(如果它不是有效的目录或文件)都将被忽略并路由到站点根目录中的index.php。然后,我使用
$\u SERVER['REQUEST\u URI']
将其作为单个参数访问,我可以使用
explode(“/”,$\u SERVER['REQUEST\u URI'])对其进行分解
,这将为我提供一个从每个值的索引0开始的数组。使用此脚本,我仍然能够访问$\u GET变量,只要在URI末尾使用了约定
?var\u name=value


这已经过测试,适用于Apache、PHP5,适用于基于debian的linux操作系统以及Windows安装的Apache。

您的规则在我的服务器上运行。定义不工作!它如何不工作?期望的结果/rewirte/url是什么?您的规则在我的服务器上运行。定义不工作!它是如何不起作用的?期望的结果/重新布线/url是什么?您实际得到了什么?