routes question |
[eluser]adt6247[/eluser]
Hi... I just recently re-wrote my personal web site using CodeIgniter -- it's so much cleaner now! Best of all, the URL's are comprehensible by humans! I'm having a problem setting up routes. I want the links on my old site to redirect to what they will be now. On my old site, the page URL's looked like this: /page.php?pid=1 on my new site, they look like this: /page/view/1 I tried setting up the following route: $route['page.php?pid=:num'] = "page/view/$1"; But no luck. What am I doing wrong? I also tried putting () around the :num, and I tried :any.
[eluser]TheFuzzy0ne[/eluser]
Try this: Code: $route[‘page\.php\?pid=(:num)’] = “page/view/$1”; # <-- Note: the . and the ? are escaped, and the :num is captured The code's not been tested, but should work.
[eluser]pistolPete[/eluser]
If you are using apache I'd recommend using mod_rewrite and a HTTP redirect. As a result, search engines will only index your new sites in future.
[eluser]adt6247[/eluser]
[quote author="TheFuzzy0ne" date="1237185514"]Try this: Code: $route['page\.php\?pid=(:num)'] = "page/view/$1"; # <-- Note: the . and the ? are escaped, and the :num is captured The code's not been tested, but should work.[/quote] Didn't work... thanks for the attempt.
[eluser]adt6247[/eluser]
[quote author="pistolPete" date="1237217763"]If you are using apache I'd recommend using mod_rewrite and a HTTP redirect. As a result, search engines will only index your new sites in future.[/quote] I can't figure out how to get that to work... This is the best I could come up with: RewriteCond ^(.*)$ page.php\?pid=$1 RewriteRule ^(.*)$ /index.php\?/page/view/$1
[eluser]adt6247[/eluser]
I found an adequate solution to this problem. I put the following code in error_404.php: Code: $remap_list = array( 'page.php?pid=' => '/page/', |
Welcome Guest, Not a member yet? Register Sign In |