2014-10-08 42 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查詢字符串。