如何编写RewriteRule来进行重定向

时间:2010-10-25 15:47:08

标签: apache .htaccess mod-rewrite

我想使用.htaccess文件将html和xml文件和目录重写为pagename查询字符串。像这样:

mysubsite / category_1 / category_2 / mysubsite / category_1 / category_2 /的file1.html mysubsite / category_1 / category_2 / file2.152.html

的index.php?页面名= category_1 / category_2 / 的index.php?页面名= category_1 / category_2 /的file1.html 的index.php?页面名= category_1 / category_2 / file1.152.html

谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

你有

mysubsite / category_1 / category_2 / mysubsite / category_1 / category_2 / file1.html mysubsite / category_1 / category_2 / file2.152.html

index.php?pagename = category_1 / category_2 / index.php?pagename = category_1 / category_2 / file1.html index.php?pagename = category_1 / category_2 / file1.152.html

我想你的意思是:

mysubsite / category_1 / category_2 /

mysubsite / category_1 / category_2 / file1.html

mysubsite / category_1 / category_2 / file2.152.html

index.php?pagename = category_1 / category_2 /

index.php?pagename = category_1 / category_2 / file1.html

的index.php?页面名= category_1 / category_2 / file1.152.html

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteRule ^mysubsite/(.*) index.php?q=$1 [NC,L,QSA]
</IfModule>
相关问题