views:

38

answers:

2

Hello everyone.

My question may look similar to others, but it's different as you'll se:

I have 5 CI apps running with the same System Folder, as described in CI User Guide. Now, I want some .htacces file to remove just the .php from the url, like, as example: http://example.com/appName/controller/action instead of http://example.com/appName.php/controller/action (removing the .php portion of the url)

Can I do that? I have no experience with .htaccess files. Also, I'm developing the site in Windows 7 with XAMPP, to deploy the site to a LAMP server.

Thanks in advance

A: 

check code igniter manual. It has a chapter for that purpose http://codeigniter.com/user_guide/general/urls.html

Removing the index.php file

By default, the index.php file will be included in your URLs: example.com/index.php/news/article/my_article

You can easily remove this file by using a .htaccess file with some simple rules. Here is an example of such a file, using the "negative" method in which everything is redirected except the specified items: RewriteEngine on RewriteCond $1 !^(index.php|images|robots.txt) RewriteRule ^(.*)$ /index.php/$1 [L]

In the above example, any HTTP request other than those for index.php, images, and robots.txt is treated as a request for your index.php file.

sebastian_h
ok, sorry if my question wasn't clear, but what I really need, is not to "redirect" all request to a index.php, I need to 'redirect' like example.com/appName1.php/controller to example.com/appName1/controller and example.com/appName2.php/controller to example.com/appName2/controller, just removing the .php of the request
josecortesp
ok, check the example because it is offering a rewrite condition to be placed into the htaccess where index.php is removed only, and all the other details are still in at the URL.
sebastian_h
to be more specific, index.php or the way you name it at code igniter will always be part of the url. You can have www.domain.com/app/index.php/news/article/my_article removing with that rewrite rule the index.php.
sebastian_h
+1  A: 

Try This

RewriteEngine on
RewriteBase /
# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) appName/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ appName.php/$1 [QSA,L]
JapanPro