Reputation: 719
i have a wee bit of a problem.
I'm currently working on a website addition to a running site. now the current website is written in a random framework which i was not able to recognize, and because the addition is rather extensive i'm doing it from scratch using CodeIgniter.
now i added my files to the server under and leading file name of 'business.php'. calling my page works well with 'www.mysite.com/business.php' but when i'm trying to call a controller with a CI call like 'www.site.co/business.php/myController' i get an error caused by the server default call to the index.php file first and that has another way of treating URIs.
can anyone please tell me what can i do to bypass the original file?
tnx for the time and help.
Upvotes: 3
Views: 3731
Reputation: 26101
Create .htaccess file in your project root directory and paste this...
DirectoryIndex index.php
RewriteEngine On
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
Next go to "config/config.php"
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = 'index.php';
change this to
$config['index_page'] = '';
That's all...
Your URL :
http://www.stackoverflow.com/index.php/my_controller/my_function/param1/param2
becomes
http://www.stackoverflow.com/my_controller/my_function/param1/param2
Hope this helps!!
Upvotes: 5
Reputation: 719
ok! :) after some long research i've found an answer.
what i've done was to move the business.php file into a dedicated folder along with the System and Application folders, once that's done i've created a second .htaccess file with the above given code and placed it in the same sub-folder.
and finally, instead of calling to 'mysite.com/business.php/myController' i need to call to 'site.com/business/business/php/myController'
that way BOTH sites work perfectly fine!
another thing though, i'd love it if some one could tell me what code to i need to use in the .htaccess file to change all my long URL to a nicer one, i've tried the common commands but they didn't work.
thank you all so very much for your tries.
Upvotes: 0
Reputation: 769
If you don't need the index.php page the simplest thing to do would remove it.
The next option is to set the default home/landing page via your .htaccess file. Using this file you can set the homepage to whatever you want.
The code will look something like this DirectoryIndex index.php index.html site-down.php
Change those files names to whatever best suits you and your default page to land on when people come to your site should change.
Upvotes: 1