CodeIgniter Forums
.htaccess trouble - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: .htaccess trouble (/showthread.php?tid=29298)

Pages: 1 2


.htaccess trouble - El Forum - 04-05-2010

[eluser]dennismonsewicz[/eluser]
In my htaccess file I am stripping out not only the index.php from the URL but I am also stripping out another piece of the URL to make everything work as it should. I have introduced a folder inside of my controller directory and with the way my htaccess file is setup, I cannot access those files in that directory.

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

    #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
    RewriteRule ^(.*)$ index.php?/welcome/$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>

I have no idea how to tell my htaccess file to read out of the admin folder... any ideas?


.htaccess trouble - El Forum - 04-06-2010

[eluser]Sean Gates[/eluser]
You need to check for a directory name as well using !-d in the RewriteCond. Like so:

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

    #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 !-d
    RewriteRule ^(.*)$ index.php?/welcome/$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>



.htaccess trouble - El Forum - 04-07-2010

[eluser]dennismonsewicz[/eluser]
When I do your suggestion I receive a 500 internal server error


.htaccess trouble - El Forum - 04-07-2010

[eluser]Sean Gates[/eluser]
Try:
Code:
RewriteCond %{REQUEST_FILENAME} !-fd

... and let me know. -d is the identifier for a directory. Per this document: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteCond


.htaccess trouble - El Forum - 04-07-2010

[eluser]Sean Gates[/eluser]
Actually, try:

Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !-d



.htaccess trouble - El Forum - 04-07-2010

[eluser]InsiteFX[/eluser]
If your running on Windows localhost you need to change the
.htaccess file from this.

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

    #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
    RewriteRule ^(.*)$ index.php?/welcome/$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>

To this:

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

    #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
    RewriteRule ^(.*)$ index.php?/welcome/$1 [L]
</IfModule>

<IfModule !mod_rewrite.so>
    # 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>

Notice the change from .c to .so.

InsiteFX


.htaccess trouble - El Forum - 04-08-2010

[eluser]dennismonsewicz[/eluser]
[quote author="Sean Gates" date="1270697733"]Actually, try:

Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !-d
[/quote]

Ok... so if I go to: http://myurl.dev/admin/authorize (.dev is my virtual host address) I get a 404 CI error... but if I go to: http://myurl.dev/index.php?/admin/authorize everything works like it should...

Any thoughts there?

Updated .htaccess file

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

    #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_URI} !-d
    RewriteRule ^(.*)$ index.php?/welcome/$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>



.htaccess trouble - El Forum - 04-08-2010

[eluser]dennismonsewicz[/eluser]
bump


.htaccess trouble - El Forum - 04-12-2010

[eluser]dennismonsewicz[/eluser]
Any help with this?


.htaccess trouble - El Forum - 04-12-2010

[eluser]danmontgomery[/eluser]
Have you tried changing the value of $config['uri_protocol'] in config.php?