我已经阅读了之前的SO问题并阅读了教程,但我不完全理解mod_rewrite,所以我在这里发帖
Options +FollowSymLinks
RewriteEngine On
#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]
RewriteRule ^profile/([0-9]+)/ /profile.php?userid=$3 [NC, L]
我想带www。 domain.com / profile.php?userid=2343 并将 URL 重写为干净的 URL,即 www.domain 。 com/profile/2343/
我尝试了多种变体..上述 .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]