Welcome Guest, Not a member yet? Register   Sign In
the dreaded mod_rewrite mac snow leopard its working but not for CI
#1

[eluser]simon_davies[/eluser]
Now I believe i have mod rewrite working as I have run an independent small test script and this seems to be working fine.

Now when I go into my CI files etc its does not seem to work.

a little bit about the structure for more information.

Settings:
Code:
$config['base_url']    = 'http://localhost/SITEFOLDER/cms/';
$config['index_page'] = '';

htaccess file
This file is located within the applications folder with the following code within

Code:
RewriteEngine On
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

If i have the following within the url
Code:
http://localhost/SITEFOLDER/cms/index.php/mgr
or
Code:
http://localhost/SITEFOLDER/cms/index.php/mgr

work fine then clicking a submit button takes me to

Code:
http://localhost/SITEFOLDER/cms/mgr/mainmenu

now this does not work because I have removed the index.php from the config fiel above, but if I link it with the the index.php name in there it works as below:

Code:
http://localhost/SITEFOLDER/cms/index.php/mgr/mainmenu

Now my externally settings like apache / config files seem to all be ok as I have run a separate folder / site with a mod_rewrite test code and all seems ok

so must be something I am or missing in my code but have followed what i have found.

I have also added a .htaccess file with the following within the root of the following folder:
Code:
http://localhost/SITEFOLDER/cms/

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

Using iMac running localhost server on snow leopard latest edition. I am using localhost direct and NOT using localhost/~user/sites.

But still nothing, any help would be appreciated.

Thanks Si

Quote:Sorry, correction if I have the <IfModule mod_rewrite.c> tag within my .htaccess file then I get a 500 internal error message, were as if these are removed then I get a 404 not found message

Thanks
#2

[eluser]johnpeace[/eluser]
Try this:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>
#3

[eluser]simon_davies[/eluser]
Thanks for the reply johnpeace, but unfortunately this still does not work.

Folder structure etc for ref:

With in my root I have a folder called say SUBFOLDER within here is the CI folders applications, system and the index.php page.

If i keep the htaccess page within the applications folder where it was originally, then i get the 404 Error page not found when I run the link: ....//localhost/SITENAME/SUBFOLDER/mgr/mainmenu, but if I then put the code into the root of the SUBFOLDER i get the follwoing 500 error,

Internal Error - The server encountered an internal error or misconfiguration and was unable to complete your request...

But if I put the index.php page name back eg:http://localhost/SITENAME/SUBFOLDER/index.php/mgr/mainmenu then it still all works fine.


Thanks Si
#4

[eluser]Unknown[/eluser]
If CI is installed in SITEFOLDER, your base url should look like this:

$config['baseurl'] = "http://localhost/SITEFOLDER/";

Yours has 'cms/' at the end.

The .htaccess file should be in the root of the SITEFOLDER. Be sure NOT to put a / before /index.php in the .htaccess folder or it will take you back to the root of localhost and not your SITEFOLDER.

After doing all of this, autoload the URL Helper in CI and add this to each HTML to make the relative links work correctly:

&lt;base href="&lt;?php base_url(); ?&gt;"/&gt;

Make sure all of your links are relative to the SITEFOLDER.
#5

[eluser]simon_davies[/eluser]
Right i have started form scratch:

I downloaded CI 2.0.2, then I have placed this into a folder called NEWSITE.

I run this with out modifications and all worked as you would expect and the welcome page was called.
localhost/NEWSITE/index.php/welcome

No sooner that i move the .htaccess page into the root from the applications folder, then add the code from CI Wiki, I get a 500 error:

Code:
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Now if I remove the <IfModule mod_rewrite.c> tags the page goes back to normal but still does not remove the index.php name.

localhost/NEWSITE/index.php/welcome

and errors if i use (page not found)

localhost/NEWSITE/welcome

any one now of a video tut that I could possibly follow to ensure that I am doing this right etc

So am complexed to why this is not working...




Theme © iAndrew 2016 - Forum software by © MyBB