Welcome Guest, Not a member yet? Register   Sign In
stop 404 if ? or & in URL
#1

[eluser]faceh[/eluser]
I have recently updated an old version of an eCommerce website which previously relied on query strings such as index.php?page=thispage&options=theseoptions&etc;...

Now I use the codeigniter friendly urls /like/this/instead

However, a lot of search engine results and external links still point to the old URLs. Currently, Codeigniter just dies and says "The URI you submitted has disallowed characters." or gives a 404 Page not found.

I want to catch all of these requests and send them to my new pages. I have tried using routing, but it seems when there is a disallowed character it doesnt even get as far as the routing class.

Any Ideas?
#2

[eluser]Mark van der Walle[/eluser]
The best way is to identify the old URLs and see to what new URLs they need to go and then in your .htaccess do something similar to:
Code:
RewriteRule ^oldpath$ newpath [L,R=301]

Ofcourse you would want that with a bit more regexing. The 301 tells search engines that the content has moved permanently (which ofcourse it sort of has).

If you can identify the pattern it is quite easy actually.
#3

[eluser]PauloBr[/eluser]
You need remapped your URLs for follow the rules of your system.

Look this article of userguide for more information about URLs in CI.
#4

[eluser]faceh[/eluser]
Paulo - that doesnt work when the URL has ? or & in it.

Mark - I want to catch all requests that start with catalog/ and contain ? or &
What RewriteRule should I use for that?
#5

[eluser]Mark van der Walle[/eluser]
I know that can be done with CI but in my opinion you should not write "hacks" in your application when the mod_rewrite solution does not influence your application. Also after a few months search engines will have lost the old URLs and are using the new ones.
#6

[eluser]faceh[/eluser]
I dont want to write hacks...

I want to include a mod_rewrite line to catch all URLs with "catalog" at the start (the base dir of the old site, not used in new one) and redirect them to my new base url. Do you know the mod_rewrite case I will need?

Quote:Also after a few months search engines will have lost the old URLs and are using the new ones.

Search engines yes. Permalinks in peoples blogs, etc. will not.




Theme © iAndrew 2016 - Forum software by © MyBB