Welcome Guest, Not a member yet? Register   Sign In
.htaccess - redirect old link to new link
#1

[eluser]dootzky[/eluser]
Hi guys,

this is my situation:

- I'm doing a remake of an existing site
- I've done everything in CI, ofcourse
- I have controller "article.php", which expects ID of the article (/base_url/article/84), and shows that article from the database

now, the tricky part:
- the "old site", had a page called "article.php", and it expected a GET parameter (there was no framework in that few-years-old code), and this is the old link google will look for: /base_url/article.php?id=84

so - is there any way that I can say to .htaccess file to redirect all hits from "article.php?id=84" to "/article/84/" ?

I did alot of reading, forum searching, but I can't find this thing I'm looking for.

So far, I've managed to do this:

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|article\.php|public|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]

and it works in a way. It allows me to get to the "old article.php file", and when I get there, I can redirect, but the thing is - my controller has the same name as the article.php page, so everytime I redirect it, I get an infinite loop.

here's an example. if I go to this link:

www.mysite.com/article.php?id=84
(and in that "article.php" file I just say => redirect-to-article/84)

I successfully get redirected to this link:
www.mysite.com/article/84

BUT, for some reason, when I get to CI controller (the second link), .htaccess file treats it like it's still the "old article.php file", and I get an infinite loop.

:|

is there a better way to do this other then .htaccess file?
I get the feeling that I must at least allow page access to the old 'article.php' file in .htaccess, or how else would the "google bot" get to that old page?

Thanks for your help, I hope I gave you enough info to help me out here. Smile
Cheers,
dootzky


Messages In This Thread
.htaccess - redirect old link to new link - by El Forum - 09-14-2008, 03:37 AM
.htaccess - redirect old link to new link - by El Forum - 09-14-2008, 02:18 PM
.htaccess - redirect old link to new link - by El Forum - 09-14-2008, 04:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB