views:

54

answers:

2

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>
A: 

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.

greg
hi there it seems that the code didn't worked. I updated this post so you can see the new .htaccess. it is actually in cakephp
jun
Your .htaccess is doing more than what you ask in your question so I can't help you there but you do have a typo `IfMaodule`. Check out the documentation for `mod_rewrite` if you're doing anything else incorrectly, it's just basic regular expressions. http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
greg
i got that typo fixed. i need it fix so I created a main.php in the webroot folder and did some redirection, it's temporary. thanks for your time.
jun
A: 

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:

Redirect 301 /main.php?page=pages&id=gettingpaidfortakingsurveys http://www.domain.com/main/pages/getting-paid-for-taking-surveys
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^$ app/webroot/    [L]
    RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

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/...?

Leo