Bellow是我的基本.htaccess代码
Options +FollowSymLinks
RewriteEngine on
RewriteBase /artist/
RewriteRule ^member/([^/]*)$ /artist/index.php?member=$1
Bellow是我的静态.htaccess代码
Options +FollowSymLinks
RewriteEngine on
RewriteBase /artist/
#we module doing some action
RewriteRule ^member/([^/]*)/([^/]*)/action/([^/]*)/$ /artist/index.php?member=$1&module=$2&action=$3
#action operation e.g create
RewriteRule ^member/([^/]*)/([^/]*)/action/([^/]*)/opt/([^/]*)/$ /artist/index.php?member=$1&module=$2&action=$3&opt=$4
#if only module calls
RewriteRule ^member/([^/]*)/([^/]*)/$ /artist/index.php?member=$1&module=$2
RewriteRule ^member/([^/]*)/([^/]*)/opt/([^/]*)/$ /artist/index.php?member=$1&module=$2&opt=$3
RewriteRule ^member/([^/]*)$ /artist/index.php?member=$1
RewriteRule ^member/0/$ /artist/index.php?member=$1
RewriteRule ^member/([^/]*)/([^/]*)/opt/([^/]*)/$ /artist/index.php?member=$1&module=$2&opt=$3
RewriteRule ^member/([^/]*)/([^/]*)/opt/([^/]*)/topicId/([^/]*)/$ /artist/index.php?member=$1&module=$2&opt=$3&topicId=$4
任何人都可以帮我编写动态RewriteRule来在我的RewiteRule中添加查询sting,这样我就不必手动添加RewriteRule而且还会减少我的.htaccess代码行
有点像:
RewriteRule ^member/([^/]*)[dynamic code]$ /artist/index.php?member=$1[dynamic code here]
答案 0 :(得分:1)
此时,您将所有请求重写为/artist/index.php
而不构建查询字符串,index.php
检查请求URI以填充其自己的变量。
即。只有一个规则
RewriteRule ^member/.* /artist/index.php
index.php可以在斜杠上查看$_SERVER['REQUEST_URI']
,explode
等。
mod_rewrite的工作不是实现复杂的逻辑。你把它放在你的申请表中。