I have a problem with CodeIgniter .htaccess file and hope that somebody can help me!
I don't know regular expressions or how to use the .htaccess, I'm very new with this things!
My Problem is:
I have this structure of files (multi application):
- application
- admin
- site
- system
- index.php
- admin.php
And this .htaccess (that works fine on localhost!)
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index.php|images|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
What I want to do is:
Access my web site (frontend) with http://www.mydomain.com/
And my admin (backend) as http://www.mydomain.com/admin/
I don't know why this works fine on my local server.
I hope someone can help me.
UPDATE
I got it to work using this:
RewriteEngine on
# If the user types "index.php" or "admin.php".
RewriteCond $1 !^(index.php|admin.php|images|robots.txt)
# If the user types just "admin".
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^admin$ admin.php [L,QSA]
# If the user enter in any admin section, like "admin/section".
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^admin/(.*)$ admin.php/$1 [L,QSA]
# If the user types any site section, like "site/section".
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
This way I can access http://www.mydomain.com/admin or http://www.mydomain.com/admin/any-section (that points to "admin.php" on the root directory)
And I can access http://www.mydomain.com/ or http://www.mydomain.com/any-section (that points to "index.php" on the root directory)
Thanks for the help!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…