[$config['index_page'] = ""] still requires index.php in url |
[eluser]pmhart[/eluser]
I have been trying to get my server working with codeigniter using a directory URI system. I have the latest version installed. I set the following in my config: $config['index_page'] = ""; And this is my htaccess file: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php?/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] </IfModule> <IfModule !mod_rewrite.c> ErrorDocument 404 /index.php </IfModule> For some reason, when I go to the site it still requires index.php to get the controller I expected. domain.com/index.php/controller but what I want is this domain.com/controller I emailed my server support and they said mod_rewrite is enabled... I see the CI 404 page when I go to domain.com/controller, so because its not the default server 404, I know CI is being called. This is why I think it might be my config, it's like I never updated it ... Is the config cached somehow? Thanks!
[eluser]pmhart[/eluser]
On second thought, htaccess redirecting to the index.php 404 ... I will keep working with the server support.
[eluser]Kamape[/eluser]
Tried to var_dump($_SERVER) to find out what values are passed to CI? When using PHP as CGI sometimes PATH_INFO isn't presented in the $_SERVER global. This can sometimes mess up your router class.
[eluser]pmhart[/eluser]
[quote author="Kamape" date="1246926838"]Tried to var_dump($_SERVER) to find out what values are passed to CI? When using PHP as CGI sometimes PATH_INFO isn't presented in the $_SERVER global. This can sometimes mess up your router class.[/quote] I added the dump to my show_404 and I'm not seeing PATH_INFO ... Do I have to manually set it with the code in the router class?
[eluser]pmhart[/eluser]
[quote author="pmhart" date="1246927556"][quote author="Kamape" date="1246926838"]Tried to var_dump($_SERVER) to find out what values are passed to CI? When using PHP as CGI sometimes PATH_INFO isn't presented in the $_SERVER global. This can sometimes mess up your router class.[/quote] I added the dump to my show_404 and I'm not seeing PATH_INFO ... Do I have to manually set it with the code in the router class?[/quote] Quick update, I changed it to AUTO and it works. I was looking at the router class, and the logic seems way wrong. Anyway, thanks!
[eluser]Kamape[/eluser]
[quote author="pmhart" date="1246927556"][quote author="Kamape" date="1246926838"]Tried to var_dump($_SERVER) to find out what values are passed to CI? When using PHP as CGI sometimes PATH_INFO isn't presented in the $_SERVER global. This can sometimes mess up your router class.[/quote] I added the dump to my show_404 and I'm not seeing PATH_INFO ... Do I have to manually set it with the code in the router class?[/quote] Sorry, what i meant was the URI.php library class. I've encountered a problem when you haven't PATH_INFO set. The URI parser will look in PATH_INFO, then in the QUERY_STRING. Finally it will take the ORIG_PATH_INFO (which i suppose you have instead) and strip out SCRIPT_NAME. The problem was that ORIG_PATH_INFO and SCRIPT_NAME had the same value. The quick (but not correct solution) is to replace line 96 in the URI.php with just: return $path; Let me know if this was any solution to your problem. The hard way I think is to made some configuration changes in PHP.
[eluser]pmhart[/eluser]
[quote author="Kamape" date="1246928332"][quote author="pmhart" date="1246927556"][quote author="Kamape" date="1246926838"]Tried to var_dump($_SERVER) to find out what values are passed to CI? When using PHP as CGI sometimes PATH_INFO isn't presented in the $_SERVER global. This can sometimes mess up your router class.[/quote] I added the dump to my show_404 and I'm not seeing PATH_INFO ... Do I have to manually set it with the code in the router class?[/quote] Sorry, what i meant was the URI.php library class. I've encountered a problem when you haven't PATH_INFO set. The URI parser will look in PATH_INFO, then in the QUERY_STRING. Finally it will take the ORIG_PATH_INFO (which i suppose you have instead) and strip out SCRIPT_NAME. The problem was that ORIG_PATH_INFO and SCRIPT_NAME had the same value. The quick (but not correct solution) is to replace line 96 in the URI.php with just: return $path; Let me know if this was any solution to your problem. The hard way I think is to made some configuration changes in PHP.[/quote] I have my uri_protocol set to "PATH_INFO" Looking at line 96, its nested in an if that says if (strtoupper($this->config->item('uri_protocol')) == 'AUTO') { ... } There is no way this code would be executed anyway ... The else statement looks like this Code: else Setting it to AUTO did work ...
[eluser]Unknown[/eluser]
Hey man, I am relatively new to CI, however I have been working with PHP for a considerable amount of time now. I am not sure whether this is the correct solution. However, you should look at some examples of how to use the .htaccess or mod_rewrite to rewrite your urls. Instead of setting your $config['index_page'] to null, leave on index.php. You need to change the way your rewrite rule works: This is simply an example of what I would do in the .htaccess file ******************************************************************* Options +FollowSymLinks Options +Indexes RewriteEngine On RewriteRule ^(.*)$ index.php?/$1 [L] // THE KEY IS THAT YOU WANT TO REWRITE ANY REQUESTS MADE TO THE INDEX SCRIPT, HENCE THE ^(.*)$ , FETCH THE REQUEST AND PARSE IT TO THE index.php? URI. RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule (.*) index.php?r=$1 [QSA,L] ********************************************** I cannot guarantee that this is the solution, however, if this does not work the first time try and look up some mod_rewrite tutorials, they should give plenty of examples on how to do this properly. Kind Regards ZeGerman
[eluser]Kamape[/eluser]
[quote author="ZeGerman" date="1247415201"]Hey man, I am relatively new to CI, however I have been working with PHP for a considerable amount of time now. I am not sure whether this is the correct solution. However, you should look at some examples of how to use the .htaccess or mod_rewrite to rewrite your urls. Instead of setting your $config['index_page'] to null, leave on index.php. You need to change the way your rewrite rule works: This is simply an example of what I would do in the .htaccess file ******************************************************************* Options +FollowSymLinks Options +Indexes RewriteEngine On RewriteRule ^(.*)$ index.php?/$1 [L] // THE KEY IS THAT YOU WANT TO REWRITE ANY REQUESTS MADE TO THE INDEX SCRIPT, HENCE THE ^(.*)$ , FETCH THE REQUEST AND PARSE IT TO THE index.php? URI. RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule (.*) index.php?r=$1 [QSA,L] ********************************************** I cannot guarantee that this is the solution, however, if this does not work the first time try and look up some mod_rewrite tutorials, they should give plenty of examples on how to do this properly. Kind Regards ZeGerman[/quote] The problem isn't in that area though, cause when adding 'index.php' to $config array, the index.php is printed on any of the anchors create by the site_url() helper. You instead want to REMOVE the index.php from your anchors and INSERT it in your .htaccess file. I'm not sure but in your example i'll guess an URL to www.example.com/index.php/show/page would route to www.example.com/index.php/index.php/show/page The problem here i'll think relays in the php server configuration or something like that. |
Welcome Guest, Not a member yet? Register Sign In |