The best way to re-route old urls |
[eluser]dobbler[/eluser]
Hi, Can anyone tell me which is the best method of re-routing old urls to the corresponding CI url? In routes, I've tried this but to no avail: Code: $route['eventsi.asp?e=(:num)'] = 'events/e/$1'; Should I be using htaccess and if so, how? Thanks in advance! Rob.
[eluser]michalsn[/eluser]
Yes, htaccess is the best solution here. Code: RewriteEngine on
[eluser]dobbler[/eluser]
@michalsn Thanks for your speedy reply! However, that does not seem to be working, here is my full htaccess code, maybe I'm doing something wrong? Code: RewriteEngine on
[eluser]mdvaldosta[/eluser]
Put the old urls to rewrite first, otherwise you're letting CI get to them and serve a 404 before you have a chance to rewrite them.
[eluser]michalsn[/eluser]
@dobbler you're right - this should work ok: Code: RewriteEngine on
[eluser]dobbler[/eluser]
[quote author="michalsn" date="1304033893"]@dobbler you're right - this should work ok: Code: RewriteEngine on Yes that works but when I put in "^eventsi\.asp?e=([0-9]+)$" it gives me the disallowed url error again. I've also tried escaping with "RewriteRule ^eventsi\.asp\?e\=([0-9]+)$ /events/e/$1 [R=301,L]" I also added in events\.asp into the RewriteCond: Code: RewriteCond $1 !^(index\.php|eventsi\.asp|resources|images|css|temp|js|robots\.txt|favicon\.ico|mailer) I just can't seem to get my head around htaccess! Thanks for your help so far! Rob.
[eluser]dobbler[/eluser]
Ok, thanks. I almost have it working.. It works perfectly on the live server so essentially, it's working fine.. However, on my local server it's redirecting a folder back Code: RewriteEngine on This works on the live server but locally I get this: When I hit: "http://www.mydomain.com/secc/eventsi.asp?e=879" (domain on local server Users/me/Sites/secc MAMP) I get redirected to this: "http://www.mydomain.com/events/e/879" Which is obviously missing the "secc" which is the folder I'm developing in. Any ideas on why this is happening and/or how to fix it? Thanks again for your help so far. Rob.
[eluser]michalsn[/eluser]
Try add secc folder to rewrite rule: Code: RewriteRule ^eventsi\.asp$ /secc/events/e/%1? [R,L] |
Welcome Guest, Not a member yet? Register Sign In |