Welcome Guest, Not a member yet? Register   Sign In
.htaccess problem when upgrading to php5
#1

[eluser]tochie[/eluser]
I changed from php 4 to php 5 and the .htaccess i was using stopped working. All links send me back to the home page. I cant figure out where the problem is from. Can someone help me look at the code?

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} ^ci-1.7.0*
    #RewriteRule ^(.*)$ /index.php/$1 [L]
    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
    #This last condition enables access to the images and css folders, and the robots.txt file
    #Submitted by Michael Radlmaier (mradlmaier)
    RewriteCond $1 !^(index\.php|images|robots\.txt|css)
    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>

Thanks a lot.
#2

[eluser]TheFuzzy0ne[/eluser]
In the config.php, try changing the URI protocol to either REQUEST_URI or QUERY_STRING. If this is the answer to your question, then I'd be interested to know what the PHP version you're running has to do with it. Did Apache upgrade too?
#3

[eluser]Daniel Moore[/eluser]
You need to check for the obvious, which may be overlooked quite easily since the setup was working for you before.

It may be, because of the new server configurations, that you need to change your CodeIgniter configuration to adapt. That is, check your $config['uri_protocol'] setting. What it was set to before may not work now.

Try each of the values listed in the comment above it one at a time ('AUTO', 'PATH_INFO', 'QUERY_STRING', 'REQUEST_URI', and 'ORIG_PATH_INFO') and see if that fixes the problem. Start with 'AUTO'.

Was it your local development machine that changed from php4 to php5? Or was it your hosting provider?

If it was your hosting provider, then quite possibly you have other server changes as well.

You need to first make sure that your mod_rewrite.c module is available. If you remove the <IfModule mod_rewrite.c> and the </IfModule>, then you get an Internal Server Error, then you know that your mod_rewrite.c module is not available.

I changed from php4 to php5 once, and many things changed with my hosting provider. One of which was (and don't ask me why, because it seems stupid to me) they actually moved me to a new server and I no longer had mod_rewrite.c but now had mod_rewrite.so.

There are definite changes I would make to your .htaccess, just because it's not as efficient as it should be. The first thing is the method you use to remove access to the system folder by users. I would remove those lines from the .htaccess file entirely, then place a separate .htaccess file IN the system folder with the following line:
Code:
deny from all

That will protect your system folder and all subfolders of your system folder. It is also more efficient, because it does not have to be checked every time a non-system folder is passed as the REQUEST_URI. This will speed things up slightly.

Also, You have 2 lines that checks to make sure a file being accessed is valid, if not, then it redirects to index.php:
Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

This is the proper way to do it. However, you have a "redundant" line as follows:
Code:
RewriteCond $1 !^(index\.php|images|robots\.txt|css)

What this line does, is allow access to images, css, index.php, and robots.txt and rewrite everything else to index.php. However, you already have access to images, css, robots.txt, etc., because as long as a valid file is addressed, it will be allowed in the previous 2 statements. This particular line will actually "change the condition" before the rewrite happens, so that your first 2 condition lines are actually no longer used. Use either the first 2 lines, or the next line, but not both.

You can set up an .htaccess file in a new directory with the following:
Code:
<IfModule mod_rewrite.c>
  AAARRGH
</IfModule>

Then place an index.php in that directory as follows:
Code:
echo "If you did not get a server error, then mod_rewrite.c is not enabled."

Navigate your browser to this new directory on your server, and you will either get a server error if mod_rewrite is installed (because AAARRGH is not a valid server command) or you will get the message stating that mod_rewrite.c is not enabled.

If you get the message instead of the error, then you might try changing mod_rewrite.c to mod_rewrite.so to test if the server is set up that way, just in case.

If this isn't enough information to help you, then you can get more details at http://www.danielwmoore.com/remove_index...odeigniter

Hope this helps.
#4

[eluser]tochie[/eluser]
@TheFuzzy0ne,

Thanks. I tried and it worked. But I hope i dont have to expect any problem because of changing from 'AUTO'. What is the best option to choose from the other variables?
#5

[eluser]TheFuzzy0ne[/eluser]
[quote author="tochie" date="1242154186"] What is the best option to choose from the other variables?[/quote]

Whichever works. Smile Sometimes AUTO doesn't work properly, so you just have to figure out which one works and set it manually.
#6

[eluser]xwero[/eluser]
[quote author="tochie" date="1242154186"]What is the best option to choose from the other variables?[/quote]
PATH_INFO, ORIG_PATH_INFO, REQUEST_URI in that order.
#7

[eluser]tochie[/eluser]
Thanks Xwero i used the REQUEST_URI. It worked better than the others.
#8

[eluser]tochie[/eluser]
@Daniel,

Thanks. I'll correct those errors and get back to you. I'll also look at your .htaccess. Mucho Gracias




Theme © iAndrew 2016 - Forum software by © MyBB