CakePHP的和.htaccess:如何重定向URL与查询字符串字符串、重定向、CakePHP、htaccess

2023-09-02 10:03:54 作者:拥梦匪若

我想重定向这个网址从/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。这会不会连字符连接的词,我不能确定,你就可以做,没有什么过于复杂的。

DA HtAccess破解版 DA HtAccess 服务器Htaccess创建工具 v3.1.3 中文版 起点软件园

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.