.htaccess URl重写目录结构

萨默尔·汗(Sameer Khan)

我在.htaccess文件中有小问题,

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为此URL我的规则不起作用,他们只是给我$ _get或$ _request only contactus

阿努巴瓦

您需要在规则中使用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]

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章