CakePHP的和.htaccess:如何重定向URL与查询字符串 [英] CakePHP and .htaccess: how to redirect url with query string

查看:118
本文介绍了CakePHP的和.htaccess:如何重定向URL与查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想重定向这个网址从/main.php?page=pages&id=gettingpaidfortakingsurveys到/主/页/获取高薪换了结的调查。

谢谢!

[UDPATE]

我测试了我现有的CakePHP的.htaccess并没有奏效。

 < IfModule mod_rewrite.c>
 RewriteEngine叙述上
 ?重写规则^ / main.php页=(+)和ID =(+)/主/ $ 1 / $ 2 [NC]
 重写规则^ $应用程序/ Web根目录/ [L]
 重写规则(。*)的应用程序/ Web根目录/ $ 1 [L]
< / IfModule>
 

解决方案

既然你似乎要与Apache的htaccess的做到这一点,你需要在的mod_rewrite 模块。在htaccess的,你会想是这样的:

  RewriteEngine叙述上
重写规则^ main.php页=(+)及?ID =(+)/主/ $ 1 / $ 2 [NC]
 

这应该让你/主/页/ gettingpaidfortakingsurveys。这会不会连字符连接的词,我不能确定,你就可以做,没有什么过于复杂的。

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>

解决方案

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:

RewriteEngine on
RewriteRule ^main.php?page=(.+)&id=(.+) /main/$1/$2 [NC]

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.

这篇关于CakePHP的和.htaccess:如何重定向URL与查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆