CodeIgniter: Multiple Apps, remove .php from url
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/con开发者_StackOverflowtroller/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
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]
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.
精彩评论