Reputation: 18845
I have been trying for hours to achieve this!
I have my codeigniter application in a subfolder of the webroot, the subfolder is called 'Tat'.
I am using the following .htaccess file in the codeigniter folder (next to the application and system folders):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#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_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.
ErrorDocument 404 /index.php
</IfModule>
If I visit: 127.0.0.1/Tat/ - I go to the CodeIgniter app, that's good.
If I visit: 127.0.0.1/Tat/index.php/register - I go to the register page of my CI app (dont want the index.php there!)
If I visit: 127.0.0.1/Tat/register - it takes me to the web root of the whole server! I want this to take me to the register page!
I have no idea how to do it!
It's worth mentioning that: * My base URL is set: $config['base_url'] = 'http://127.0.0.1:5678/Tat'; * My index page is set: $config['index_page'] = ''; * I have total control over the server, it's a development server running Apache2 on Ubuntu Precise 64.
If anyone can point me in the right direction or correct my .htaccess or tell me how to modify the apache settings that would be awesome!
Thanks.
Upvotes: 0
Views: 1670
Reputation: 18845
I have FINALLY found the answer! My server wasn't configured correctly, I didn't have mod_rewrite enabled.
Ubuntu users, fire this off on the command line to enable it: sudo a2enmod rewrite
Then restart Apache.
I am using the following .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#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_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.
ErrorDocument 404 /index.php
</IfModule>
Upvotes: 0
Reputation: 2287
Your site is in a subfolder so set the RewriteBase like so on line 4:
RewriteBase /Tat
Upvotes: 1