EllisLab text mark
Advanced Search
     
Removing index.php from URL
Posted: 10 April 2012 05:31 PM
Avatar
Joined: 2011-12-23
102 posts

I use this code in .htaccess file

<IfModule mod_rewrite.c>
    
RewriteEngine On
    RewriteBase 
/www/zayanit.com/zayan/

    
#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
    #Submitted by: Fabdrol
    #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.
    # Submitted by: ElliotHaughin

    
ErrorDocument 404 /index.php
</IfModule

and make the base_url in the config file

$config['base_url''http://www.zayanit.com/zayan';
$config['index_page'''

in autoload file

$autoload['helper'= array("html""url"); 

but I can’t use any method in the controller unless I write index.php in URL
like this
http://www.zayanit.com/zayan/site/contact
http://www.zayanit.com/zayan/index.php/site/contact

Where is my wrong?

 
Posted: 10 April 2012 05:56 PM   [ # 1 ]   [ Rating: 0 ]
Joined: 2012-03-14
11 posts
RewriteBase /zayan

That should work.

 
Posted: 10 April 2012 06:02 PM   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2011-12-23
102 posts

It works
Thank you so much.

 
Posted: 21 May 2012 12:32 PM   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2011-12-23
102 posts

If I want to put my code in the domain directly not in folder
the base_url will be

$config['base_url''http://www.zayanit.com';
$config['index_page'''
 
Posted: 21 May 2012 02:29 PM   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2009-02-19
4548 posts

Actually, base_url needs a trailing slash.

$config['base_url''http://www.zayanit.com/'
 Signature 
 
Posted: 22 May 2012 04:27 AM   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2011-12-23
102 posts

Thank you but what should I put here

<IfModule mod_rewrite.c>
    
RewriteEngine On
    RewriteBase 
???????? 
 
Posted: 22 May 2012 02:13 PM   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2007-11-28
2435 posts

Just a slash /