Reputation: 846
I have hosted a site as a sub folder like "http://www.sitename.com/projectfoldername/"
.
Here it shows only the home page and when clicked on any menu it shows 404 error ,so i changed the the url by writing index.php before the controller name now the url has changed from this:
"http://www.sitename.com/projectfoldername/controller-name/function-name"
to this: "http://www.sitename.com/projectfoldername/index.php/controller-name/function-name"
then it shows the pages but worked locally only..
my htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
config.php
$config['base_url'] = 'http://www.sitename.com/projectfoldername/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
Upvotes: 1
Views: 2289
Reputation: 247
If you used Apache Web Server, active your mod_rewrite
On Ubuntu:
sudo a2enmod rewrite
On Window:
Open your httpd.conf and Find the line
#LoadModule rewrite_module modules/mod_rewrite.so and remove the hash ‘#’
Upvotes: 1
Reputation: 406
@antroo ghosh , At first you have to know that which web server is using( Apache or IIS).
If you are using windows(IIS) server you can't use .htaccess, In IIS you have to use web.config instead of .htaccess.
For more details https://www.iis.net/learn/application-frameworks/install-and-configure-php-applications-on-iis/translate-htaccess-content-to-iis-webconfig
I hope this may helps you!
Upvotes: 0
Reputation: 284
try adding following in .htaccess, it might help you.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Upvotes: 0
Reputation: 1521
Use RewriteBase /projectfoldername
in your .htaccess
file like so:
RewriteEngine On
RewriteBase /projectfoldername
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [L]
Upvotes: 0