Welcome Guest, Not a member yet? Register   Sign In
Trying to get htaccess file to ignore a root folder
#11

[eluser]Philipp Gérard[/eluser]
Both methods work. The reason why they don't work in your environment is up to speculation. What Apache version, what modules etc. do you use on what OS that might be conflicting?
#12

[eluser]hugle[/eluser]
[quote author="The Questioner" date="1291076097"]Sorry Hugle & Vitico, I've tried both your methods and neither of them correctly force CI to ignore any processing for the "secure" folder.[/quote]

Those methods both should work. tested myself.

What are your folder structure?
and is your CI in the root folder?
#13

[eluser]The Questioner[/eluser]
I humbly offer my apologies. It's obviously something that I must be doing wrong.

This is the file structure:

Code:
public_html
->.htaccess
->secure
->system
->frontend
->core
->admin

Where ".htaccess" is the main htaccess file, "system" is the main CI folder and "secure" is a password protected folder (the one that I'm interested in).

The folder "secure" contains its own htaccess file which governs the folder's security:

Code:
AuthName "Secure"
AuthUserFile "/home/[b]<website name>[/b]/.htpasswds/public_html/secure/passwd"
AuthType Basic
require valid-user

This folder contains just one file, "barclaycard_posturl_process.php".

What I have just noticed is that if I do this to the main htaccess file:

Code:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|secure)

Then CI does indeed ignore processing the "secure" folder and the site follows normal behaviour for a password protected folder. However, the rest of the site URLs stop working (404 errors) unless I manually add the "index.php" into the appropriate place in the URL. So www.mywebsite.com/shop/brand/10, doesn't work but www.mywebsite.com/index.php/shop/brand/10 does work.
#14

[eluser]hugle[/eluser]
Hello

so if the page shows up only with index.php in the url, it means you have mod_rewrite problems.
which means mod_rewrite is disabled... or something like that Smile
#15

[eluser]The Questioner[/eluser]
If I re-introduce this line into the bottom of the htaccess file:

Code:
RewriteRule ^(.*)$ /index.php/$1 [L]

Then any URLs without the "index.php" are successfully redirected to the correct CI controller. Therefore mod_rewrite must be working. However, the inclusion of this line then stops the "secure" folder from being ignored by CI.
#16

[eluser]The Questioner[/eluser]
I'm wondering, is it just a matter of telling the htaccess file to ignore adding the "index.php" into the URL only if the URL is pointing to the "secure" folder. If this condition is true, then htaccess can immediately stop processing any further commands? Should this stop CI from processing the URL?

Can anyone advice me on this approach?
#17

[eluser]Unknown[/eluser]
I'm also having the exact issue on an EE build 1.6.7. I have a .zip of my portfolio in the root of the public site and that .htaccess line to remove "index.php" is messing things up.

Hope someone can help us.
#18

[eluser]The Questioner[/eluser]
I've finally got this sorted out – I've had to pay a htaccess specialist to get it working. I would like to share his solution with the rest of the CI community.

The main htaccess file now looks like this

Code:
#check the mod_rewrite module is enabled or not
<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    Options +Indexes
    #first start the rewrite engine
    RewriteEngine On
    #put the base directory of the root
    RewriteBase /    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    #prompt the server to send a file called 401.shtml to the browser
    RewriteCond $1 !^(401.shtml)
    RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
#if mod_rewrite is not enabled then make a error document 404
<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

He also changed the htaccess file within the "secure" folder (which previously just held the AuthUserFile details):

Code:
#Put the rewrite engine off for this subdirectory
RewriteEngine off
AuthType Basic
#put the authname here for user login
AuthName "Confidential"
#place the file here for htaccess password be sure it is located at other folder
AuthUserFile "/home/<webiste name>/.htpasswds/public_html/secure/passwd"
require valid-user




Theme © iAndrew 2016 - Forum software by © MyBB