如何首先重定向,然后使用 mod_rewrite 重写
我有两个域指向同一主机,例如 example1.com 和 example2.com。
我已经有一个重定向:
RewriteRule ^([A-Za-z0-9-]+)/$ page.php?q=$1 [L]
来捕获诸如 example1.com/hello-world/ => 之类的内容example.com/page.php?q=hello-world
现在我需要满足 3 个特定条件:
1) example1.com/special/ => example2.com/special/ [仅适用于“特殊”]
2) example2.com/ =>; example2.com/special/
3) example2.com/anything-not-special/ => example1.com/anything-not-special/
我可以实现这种情况,只是我希望将右侧栏中的内容显示在 URL 栏中。相反,我得到: example2.com/special/ => example1.com/page.php?q=special
这对我来说并不理想。
任何帮助表示感谢,谢谢!
I have two domains pointing to the same host, say example1.com and example2.com.
I already have a redirect:
RewriteRule ^([A-Za-z0-9-]+)/$ page.php?q=$1 [L]
to catch things like example1.com/hello-world/ => example.com/page.php?q=hello-world
Now I need 3 specific conditions to be met:
1) example1.com/special/ => example2.com/special/ [ONLY for "special"]
2) example2.com/ => example2.com/special/
3) example2.com/anything-not-special/ => example1.com/anything-not-special/
I can get this to happen, except that I want exactly what's in the right-hand column here to be displayed in the URL bar. Instead, I'm getting:
example2.com/special/ => example1.com/page.php?q=special
which is not ideal for me.
Any help appreciated, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看这是否符合您的要求:
See if this does what you want: