我将如何编写 RewriteRule 来进行重定向

发布于 2024-09-29 03:38:49 字数 366 浏览 1 评论 0原文

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

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

感谢您的帮助。

I want to rewrite the html and xml files and directories to the pagename query string using .htaccess file. like this :

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

Thanks for you help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

牵你手 2024-10-06 03:38:49

您有

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?pagename=category_1/category_2/file1.152.html

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

You have

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

and

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

And I'm supposing that you meant:

mysubsite/category_1/category_2/

mysubsite/category_1/category_2/file1.html

mysubsite/category_1/category_2/file2.152.html

and

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

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteRule ^mysubsite/(.*) index.php?q=$1 [NC,L,QSA]
</IfModule>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文