mod_rewrite issues |
[eluser]tix[/eluser]
I am currently in a rather strange situation. I ported a legacy php application to codeigniter and have to rewrite all the old urls to the new ones.As this application is a web service I need to keep full backward compatibility with the old version (which except GET it also sends POST variables). I currently have tried the following (sales.php is the old script and /Sale is the new url) RewriteRule sales.php /index.php/Sale -> RESULT : Codeingiter 404 page RewriteRule sales.php /index.php/Sale [QSA] -> RESULT : Codeingiter 404 page RewriteRule sales.php /index.php/Sale [R,QSA] -> RESULT: Redirect to /Sale but all POST is lost RewriteRule sales.php /index.php/Sale [R,QSA,P] -> Apache 404 page (tried to use mod_proxy to proxy POST vars). An ideal solution would be the first one (no redirect and all vars sent) but I can understand why it is giving a (in codeigniter) 404. Any help would be really appreciated.
[eluser]vitoco[/eluser]
I think the problem is that you put an "/" before index.php, so it search in the root directory of the domain, and i guess that your app is in a subdir. Also you must use lowercase in controller and method, even if the controller name start with uppercase in the php file. so try this one : Code: RewriteRule sales.php index.php/sale Note : this rule implies that sales.php and index.php reside in the same folder, so if you have your index.php ( the ci index.php ) in another dir must redirect there. Saludos
[eluser]Aken[/eluser]
Typically if you're rewriting a web application to use new URLs, you should just create a 301 Redirect (permanently moved page) to forward to the new URL. You'd use the full URL in this case. Using Redirect: Code: Redirect 301 sales.php http://www.example.com/sale Using RewriteRule: Code: RewriteRule ^sales\.php$ http://www.example.com/sale [R=301,L]
[eluser]tix[/eluser]
First of all thanks for your replies! @vitoco I was pretty sure that this is not the case but I did remove the leading slash and it did not work (the application is not in a subdir but in domain root).As for the case sensitivity it is actually Sale as it follows my naming conversion. @Aken We dont REALLY need a 301 as this is a web service and we dont really about SEO or anything.Following your example wont all $_POST data get lost? |
Welcome Guest, Not a member yet? Register Sign In |