我已经阅读了之前的问题并阅读了教程,但我不完全理解 mod_rewrite,所以我在这里发帖。 我当前的 .htaccess 是:
Options +FollowSymLinks
RewriteEngine On
#### 1st set of rules.... ####
#Using THE_REQUEST for catching references and using them later on.
RewriteCond %{THE_REQUEST} \s/(content)/index\.php\?var=(.*?)\s [NC]
RewriteRule ^ /%1/featured/%2? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(content)/featured/(.*?)/?$ $1/index.php?var=$2 [QSA,NC,L]
#### 2nd set of rules.... ####
#Using THE_REQUEST for catching references and using them later on.
RewriteCond %{THE_REQUEST} \s/(profile)\.php\?userid=(.*?)\s [NC]
RewriteRule ^ /%1%2? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(profile)/(.*?)/?$ $1.php?userid=$2 [QSA,NC,L]
我有这个网址:www.域名 .com/content/cat/build 并指向 www.域名 .com/content/catcontent.php?catvar=build ??它会遵循什么 htaccess mod_rewrite 规则?
我已经添加了这个,但它破坏了网站......
#### 3rd set of rules.... ####
#Using THE_REQUEST for catching references and using them later on.
RewriteCond %{THE_REQUEST} \s/(content)/(cat)/\catview\.php\?cattype=(.*?)\s [NC]
RewriteRule ^ /%1%2? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(content)/(cat)/catview.php/?$ $1.php?cattype=$2 [QSA,NC,L]
谢谢
我用谷歌搜索并阅读了旧帖子。 我已阅读教程。 我不太理解 mod_rewrite ,因为它看起来像一个字母数字单词沙拉,我正在寻求帮助
根据您展示的示例,请尝试遵循以下规则。在测试您的网址之前,请确保清除浏览器缓存
Options +FollowSymLinks
RewriteEngine On
#### 1st set of rules.... ####
#Using THE_REQUEST for catching references and using them later on.
RewriteCond %{THE_REQUEST} \s/(content)/index\.php\?var=(.*?)\s [NC]
RewriteRule ^ /%1/featured/%2? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(content)/featured/(.*?)/?$ $1/index.php?var=$2 [QSA,NC,L]
#### 2nd set of rules.... ####
#Using THE_REQUEST for catching references and using them later on.
RewriteCond %{THE_REQUEST} \s/(profile)\.php\?userid=(.*?)\s [NC]
RewriteRule ^ /%1%2? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(profile)/(.*?)/?$ $1.php?userid=$2 [QSA,NC,L]
##3rd set of rules from here....
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(content)/(cat)/(build)/?$ $1/$2$1.php?catvar=$3 [QSA,NC,L]