2011-06-18 168 views
0

我有一个使用PHP中表单的GET变量生成的URL。我的问题是有两个变量被传递。下面是一个例子URL澄清:对mod_rewrite问题的澄清需要

http://www.examplesite.com/example.php?first=one&second=two 

我想用一个mod_rewrite的在我的.htaccess,使这个较小的URL。我非常希望网址...

http://www.examplesite.com/one 

能够重定向到完整的URL ...

http://www.examplesite.com/example.php?first=one&second=two 

,但你可以看到有两个变量。这可能吗?如果不是,我可以使用这两个变量获取URL的最短时间是多少?

这是我目前用的mod_rewrite来解决这个尝试

RewriteEngine on 

# don't rewrite if the file exists 
RewriteCond %{REQUEST_FILENAME} !-f 
# don't rewrite if the directory exists 
RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^(.*)$ example.php?first=$1&second=$2 

回答

1

试试这个:

RewriteEngine on 

# don't rewrite if the file exists 
RewriteCond %{REQUEST_FILENAME} !-f 
# don't rewrite if the directory exists 
RewriteCond %{REQUEST_FILENAME} !-d 

# http://www.examplesite.com/one/two 
RewriteRule ^([^/]*)/([^/]*)$ /example.php?first=$1&second=$2 [L]