2014-10-08 38 views
1

我现在的htaccess文件(@anubhava提供)是htaccess的 - 通过随机变量的动态

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

# load index.php by default 
DirectoryIndex index.php 

RewriteBase/

# remove trailing slash  
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+)/$ /$1 [NE,R=301,L] 

# for all other requests load room.php 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !^/(1|2|3|4|5|6|7|8|9|10|anonymity|similarity|inconspicuous) 
RewriteRule ^((?!(index|room)\.php).+)$ room.php?u=$1 [L,NC] 

现在的工作方式是,如果有人去www.example.com它们朝着index.php。如果他们访问www.example.com/anythingelse,他们将被重定向到room.php

我有3个额外的变量可以在任何时候由用户传递。他们可能只能使用其中的1个或者可能全部使用其中的3个。另外三个变量是

redirect 
panic 
timeout 

如果我使用所有这三个URL中的它看起来像

http://www.example.com/this?panic=0&timeout=3&redirect=google.com

但正如我所说,他们可能只通过其中的一些,那么另一变异可以是

http://www.example.com/this?timeout=3&redirect=google.com

是否有可能能够动态地确定(在没有partic Ular顺序)选择了哪些变量并且能够将它们传递给room.php

回答

1

您可以通过在你的最后一条规则使用QSA标志一起传递它们:

RewriteRule ^((?!(index|room)\.php).+)$ room.php?u=$1 [L,NC,QSA] 

这会转嫁给room.php查询字符串。