Mod在查询字符串后重写文本

时间:2014-01-26 15:33:54

标签: apache .htaccess mod-rewrite query-string

我有两页: Member.php 构件-likes.php

我正在尝试制作网址结构:

www.domain.com/member = www.domain.com/member.php
www.domain.com/member/Sam = www.domain.com/member/?userID=Sam
www.domain.com/member/Sam/likes = www.domain.com/member-likes.php?userID=David

现在我的htaccess文件是:

RewriteEngine On

RewriteBase /
RewriteRule ^about about.php [L]
RewriteRule ^explore/(.*) palette.php?colID=$1 [L]
RewriteRule ^explore explore.php [L]
RewriteRule ^admin admin.php [L]
RewriteRule ^profile profile.php [L]
RewriteRule ^member/([^/]+)/likes/?$ member-likes.php?userID=$1 [L,QSA]
RewriteRule ^member/([^/]+)/?$ member.php?userID=$1 [L,QSA]
RewriteRule ^member/? member.php [L]

RewriteRule ^login login.php [L]
RewriteRule ^logout logout.php [L]

我已经阅读了很多文档,我可能会使用错误的标志或其他东西?我的主要问题是我不知道我想要做什么叫做难以搜索!

非常感谢任何帮助

谢谢

1 个答案:

答案 0 :(得分:0)

确保使用行开始/结束锚点:

RewriteEngine On
RewriteBase /

RewriteRule ^member/([^/]+)/likes/?$ member-likes.php?userID=$1 [L,QSA]
RewriteRule ^member/([^/]+)/?$ member.php?userID=$1 [L,QSA]
RewriteRule ^member/?$ member.php [L]