![]() |
Stuck with mod rewrite - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Stuck with mod rewrite (/showthread.php?tid=12526) |
Stuck with mod rewrite - El Forum - 10-22-2008 [eluser]tiono[/eluser] Desperately need help. My webroot structure : images/ include/ webadmin/ (CI folders & files inside here. I have css, images, public, system, test, tmp, and index.php) webmail/ index.php my config.php $config['base_url'] = "http://www.myweb.com/webadmin/"; $config['index_page'] = ""; $config['uri_protocol'] = "AUTO"; my routes.php $route['default_controller'] = "welcome"; It suppose to work like this : 1. When I point to www.myweb.com, I should get my website page (works already without changing anything). 2. When I point to http://www.myweb.com/webadmin, then should be redirect to http://www.myweb.com/webadmin/welcome/verify if user not login yet. I redirect using redirect("welcome/verify","refresh"); Next I already put .htaccess file in my webroot. content is : <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /webadmin/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) /index.php/$1 [L] </IfModule> Next I try accessing http://www.myweb.com/webadmin, and I was redirect to Code: http://www.myweb.com/webadmin/ //www.myweb.com/webadmin/welcome/verify Next I try accessing directly http://www.myweb.com/webadmin/welcome/verify but what i see is my website index.php Then I tried modified .htaccess become : <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /webadmin/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) /webadmin/index.php/$1 [L] </IfModule> After modified, If I type http://www.myweb.com/webadmin/welcome/verify, I can see my login form. When I enter correct login information, then page redirect to Code: http://www.myweb.com/webadmin/welcome/ //www.myweb.com/webadmin/packages It's really strange that I can get it work at my local computer with similar setup, but when I publish it on my webhosting, it is not working at all. I've search and read a lot about mod_rewrite in CI, but still couldn't find the solution. Somebody please tell me what should I change to make the website works correctly. Stuck with mod rewrite - El Forum - 10-22-2008 [eluser]Randy Casburn[/eluser] Since you've put CI in a subdirectory of your DOCROOT, and you've used AUTO in your uri_protocol, you must use the subdirectory in your uri paths. Go back to your main controller and put your subdirectory (webadmin) on your path and it should work just fine. Randy Stuck with mod rewrite - El Forum - 10-22-2008 [eluser]Huan[/eluser] Have you tried: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /webadmin/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) index.php/$1 [L] </IfModule> It works for me Stuck with mod rewrite - El Forum - 10-22-2008 [eluser]tiono[/eluser] @randy Casburn I try changing redirect from redirect("welcome/veriy","refrech") to redirect("webadmin/welcome/verify","refresh") and then access http://www.myweb.com/webadmin it failed again. Then I tried to change my redirect to use "location" instead of refresh, so it become like Code: redirect('welcome/verify','location') I change all of my redirect to use location and all works fine now. Thanks for ur help @Huan Yes that is the .htaccess that I used now. |