2014-04-10 76 views
2

我在.htaccess文件小问题,的.htaccess URL重写目录结构

RewriteEngine On 

RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?urltype=$1 [NC,L]  
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ index.php?urltype=$1&url=$2 [NC,L] 
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)?$ index.php?urltype=$1&url=$2&pages=$3 [NC,L] 

Options -Indexes 
ErrorDocument 401 /401.html 
ErrorDocument 403 /403.html 
ErrorDocument 404 /404.html 
ErrorDocument 500 /500.html 

<Files .htaccess> 
order allow,deny 
deny from all 
</Files> 

# MIME types for Video 
AddType video/mp4 mp4 m4v f4v f4p 
AddType video/ogg ogv 
AddType video/webm webm 
AddType video/x-flv flv 

这是.htaccess文件。现在我想打一个网址 这样的:domainname.com/seach/?name=Sameer&lastname=khan等,与我的其他规则也行

编辑

这一次“domainname.com/seach/,domainname.com/home/, domainname.com/contactus/“这个网址正在工作。现在我想,当我提交表单,我想使用$ _get方法。这就是为什么我需要发送像这样的变量:domainname.com/contactus/?name=Sameer & lastname = khan这个网址我的规则不工作,他们只是给我在$ _get或$ _request只有contactus

+0

澄清您的要求。 'domainname.com/seach/?name = Sameer&lastname = khan' URL有什么问题? – anubhava

+0

在这个时候**“domainname.com/seach/,domainname.com/home/,domainname.com/contactus/"**此网址正在工作。现在我想当我提交表单,我想使用$ _get方法,为什么我需要发送变量** domainname.com/contactus /?name = Sameer&lastname = khan **这个网址我的规则不工作,他们只是给我$ _get或$ _request只联系我们 –

回答

0

你需要在您的规则中使用QSA标志:

RewriteRule ^([A-Z0-9-]+)/?$ index.php?urltype=$1 [QSA,NC,L] 
RewriteRule ^([A-Z0-9-]+)/([A-Z0-9-]+)/?$ index.php?urltype=$1&url=$2 [NC,L,QSA] 
RewriteRule ^([A-Z0-9-]+)/([A-Z0-9-]+)/([A-Z0-9-]+)?$ index.php?urltype=$1&url=$2&pages=$3 [NC,L,QSA] 
+0

谢谢你的工作 –

+0

不客气,很高兴它解决了。 – anubhava