I have a site that uses ExpressionEngine in the root directory, and then has a protected installation of CodeIgniter in a subdirectory.
I’m transferring a site to be in its new domain, from a temporary location, but I’m having some issues.
The temporary location was http://servername.com/~sitename/, and I’m moving it to http://sitename.com. I used to access the protected CodeIgniter site by going to http://servername.com/~sitename/protected-site/.
I had .htaccess files set up and working perfectly on the temporary location, with the root .htaccess as:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteRule ^(.*)$ /index.php?$1 [L]
And the CodeIgniter subdirectory (“protected-site”) as:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /~sitename/protected-site/
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>
AuthUserFile /home/sitename/www/protected-site/.htpasswd
AuthType Basic
AuthName "Aerie Backcountry Medicine - Database Administration"
Require valid-user
When I view the site at its new location (sitename.com), everything works fine - links are great, mod_rewrite seems to be working perfectly. However, when I try to go to the protected area, by going to http://sitename.com/protected-site/, I just see the home page of the main root site.
Doing some messing around, I found that If I delete the Auth section of the ‘protected-site’ subdirectory’s .htaccess file, so it just says:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /~sitename/protected-site/
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>
I’m able to view the it fine by going to http://sitename.com/protected-site/, and everything works perfectly (except that there’s no authentication to get there, obviously).
I can’t figure out why:
1] My .htaccess files worked perfectly before, but now they don’t,
and 2] why removing the Auth section of the .htaccess file would then make all of the mod_rewrite stuff work fine.
I’m not really a pro at .htaccess stuff, but I do understand the basics… But I can’t figure this out.
Thanks in advance for any help.