我正在使SEO对网站更加用户友好,通过这里我发现了mod_rewrite。我已根据我所看到的内容编写了一些代码,但在将其放入.htaccess文件之前,我想确保它看起来正常。我真的不想在现场网站上乱用.htaccess文件,所以我基本上只是在寻找一些保证,这个代码看起来可以使用。
RewriteEngine On
RewriteRule ^case-study-cff-campaign/?$ casestudy.php?casestudyid=10
RewriteRule ^case-study-prohockeymindset/?$ casestudy.php?casestudyid=14
RewriteRule ^case-study-CFNU-convention-2013/?$ casestudy.php?casestudyid=16
RewriteRule ^case-study-CFNU-research-to-action/?$ casestudy.php?casestudyid=19
RewriteRule ^case-study-Accountapotamus/?$ casestudy.php?casestudyid=21
RewriteRule ^case-study-Balance-Relaxation-Therapy/?$ casestudy.php?casestudyid=23
RewriteRule ^case-study-PQCHC/?$ casestudy.php?casestudyid=25
RewriteRule ^case-study-ULTC/?$ casestudy.php?casestudyid=27
RewriteRule ^case-study-Community-Forward-Fund/?$ casestudy.php?casestudyid=269
RewriteRule ^case-study-Chartier-Physiotherapy/?$ casestudy.php?casestudyid=4
答案 0 :(得分:0)
该代码看起来可以在htaccess文件或<Directory>
容器中使用,因为在这些情况下会删除前导斜杠。在服务器或虚拟主机中,您需要在所有这些前面使用前导斜杠。
此外,您可能希望添加L
标志或QSA
标志,以免丢失查询字符串参数:
RewriteRule ^case-study-cff-campaign/?$ casestudy.php?casestudyid=10 [L,QSA]
您的每条规则。