2
votes

I am using codeigniter. I have front end application and backend application like

/system/

/application/

   /front/

   /admin/

index.php

admin.php

.htaccess

I want my url like http://example.com/news/article1 (for site) http://example.com/news/admin (for admin)

In .htaccess I have written

RewriteEngine On
# 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]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d    
RewriteRule ^(.*)$ index.php?/$1 [L]

the front end is working fine but when I enter mydomain.com/admin it is throwing 404 not found error. Please help me.

Thanks and regards

1

1 Answers

1
votes

I'm not that good with .htaccess, but from the CI website, you can use this for your .htaccess rule

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

and then use routes to rewrite your urls. Much easier than trying to do it in .htaccess files