CakePHP 和 .htaccess:如何使用查询字符串重定向 url
我想将此网址从 /main.php?page=pages&id=gettingpaidfortakeingsurveys 重定向到 /main/pages/getting-paid-for-takeing-surveys。
谢谢!
[UDPATE]
我在现有的 cakephp .htaccess 上测试了它,但它不起作用。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/main.php?page=(.+)&id=(.+) /main/$1/$2 [NC]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
I wanted to redirect this url from /main.php?page=pages&id=gettingpaidfortakingsurveys to /main/pages/getting-paid-for-taking-surveys.
Thanks!
[UDPATE]
i tested it on my existing cakephp .htaccess and it didn't work.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/main.php?page=(.+)&id=(.+) /main/$1/$2 [NC]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于您似乎想要使用 Apache 的 .htaccess 来执行此操作,因此您需要
mod_rewrite
模块。在 .htaccess 中,您需要类似的内容:这应该让您 /main/pages/gettingpaidfortakeingsurveys。这不会对单词进行连字符,我不确定您是否能够在没有过于复杂的情况下做到这一点。
Since you appear to want to do this with Apache's .htaccess, you'll need the
mod_rewrite
module. In the .htaccess, you'll want something like:This should get you /main/pages/gettingpaidfortakingsurveys. This won't hyphenate the word and I'm unsure you'll be able to do that without something overly complex.
您尝试过吗?我假设这只是一页的重定向。您需要将其放在 Cake 重写块上方。第二部分必须是完整的 URL:
如果重写是临时的,请用 302 替换 301。url
的 /main 部分看起来不太适合 Cake。不应该只是/pages/...吗?
Have you tried this, I'm assuming that this is a redirect for one page only. You'll need to put it above the Cake rewrite block. The second part must be the full URL:
If the rewrite is temporary, substitute 302 for 301.
The /main part of the url doesn't look very Cake-friendly. Shouldn't it just be /pages/...?