CodeIgniter Forums
Rewrite issue with CI 1.7.2 -> 2.0.2 upgrade - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Rewrite issue with CI 1.7.2 -> 2.0.2 upgrade (/thread-43185.html)



Rewrite issue with CI 1.7.2 -> 2.0.2 upgrade - El Forum - 07-03-2011

[eluser]kettch[/eluser]
I just upgraded one of my sites using CI 1.7.2 to 2.0.2 using the documentation article dedicated to the upgrade steps.

Everything works fine EXCEPT I can no longer use http://<address>/<view> instead of http://<address>/page/id/<view> as I get a 404 with http://<address>/<view>

My htaccess file is the same as it has been for years and if I revert the upgraded files in the /system directory then everything works as expected again so something must have changed in the newer versions that wasn't documented.

Does anyone have an idea what might cause this issue?


Rewrite issue with CI 1.7.2 -> 2.0.2 upgrade - El Forum - 07-04-2011

[eluser]toopay[/eluser]
Did you use route, hook, _remap or some of PHP magic method for that? Give a clear explanation of your issues rather than a simple "Does anyone have an idea what might cause this issue?"


Rewrite issue with CI 1.7.2 -> 2.0.2 upgrade - El Forum - 07-05-2011

[eluser]kettch[/eluser]
No need to be testy, it's been a couple of years since I've touched the CI code for this site and I couldn't find any errors so there wasn't any additional information that I could see otherwise I'd have posted that as well. I figured it is probably a relatively common issue for people that go through the upgrade process so I just wanted a direction to look rather than stabbing in the dark.

Anyway, I don't have any routes or hooks defined. Pretty sure it is just using htaccess to do the rewrite. The htaccess did not change as I mentioned and works fine when I revert to the old /system code. The only thing in routes.php is defining my default controller (page).


Rewrite issue with CI 1.7.2 -> 2.0.2 upgrade - El Forum - 07-05-2011

[eluser]toopay[/eluser]
[quote author="kettch" date="1309899091"]just wanted a direction to look rather than stabbing in the dark.[/quote]

To achieve 'http://yourdomain.com/foo' url like, someone ussually use route, hook, remap or some PHP magic method, thats why i ask for that. You say you use htaccess, then at least post your htaccess code here.

There no such information to process in your previous post. The main difference of CI 1.7.2 to 2.0.x is just you need to add a 'CI_' prefix before Controller and Model class. If you didn't use some fancy method, thats would be it.


Rewrite issue with CI 1.7.2 -> 2.0.2 upgrade - El Forum - 07-05-2011

[eluser]kettch[/eluser]
My htaccess that has been in production for several years now is:

Code:
RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteRule ^(index.html)$ $1 [L]
RewriteRule ^((images|styles|scripts|documents)/*.*)$ $1 [L]
RewriteRule ^(admin/*)$ index.php/$1 [L]
RewriteRule ^([a-zA-Z0-9]+)$ page/id/$1
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php/$1 [L]

After discovering this little rewrite problem I simplified it a bit with the same result:

Code:
RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteRule ^([a-zA-Z0-9]+)$ page/id/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Other than that, this site is pretty simple, 4 controllers, 2 models and about a dozen views. No additional custom helpers, libraries or routes beyond the core CI stuff.

I've also gone through all of the 1.7.2 core code to see if there was any custom code added there but have found none, so I'm a bit stumped.


Rewrite issue with CI 1.7.2 -> 2.0.2 upgrade - El Forum - 07-06-2011

[eluser]kettch[/eluser]
I've done a diff of all the files in /system compared to the default 1.7.2 files and they are all identical except for the obvious /system/application files so I'm not missing any CI customizations when I moved to 2.0.2.

Here is my RewriteLog output: http://pastebin.com/b8T8Hu1D

You can see the rewrite gets applied correctly and ends up with:

http://<address>/<subdir>/index.php/page/id/faq

However, this returns a 404 whereas manually typing in the exact same URL into the browser returns the content correctly. The RewriteLog when using the manually typed-in URL has all of the same output except it obviously skips the need to go from <view> to /page/id/<view>.

Does anyone have ideas? I'm getting no errors in the Apache logs or the PHP logs at all other than the generic 404 in the browser. Again, this issue only occurs when I upgraded from 1.7.2 to 2.0.2. If I revert all of the 2.0.2 CI files to 1.7.2 then it works correctly.


Rewrite issue with CI 1.7.2 -> 2.0.2 upgrade - El Forum - 07-07-2011

[eluser]osci[/eluser]
Have you gone through these? Maybe they help.
User Guide - Upgrading and User Guide - Changelog


Rewrite issue with CI 1.7.2 -> 2.0.2 upgrade - El Forum - 07-07-2011

[eluser]kettch[/eluser]
[quote author="osci" date="1310039033"]Have you gone through these? Maybe they help.
User Guide - Upgrading and User Guide - Changelog[/quote]

Yeah, these were the docs I used to perform the upgrade.