重写URL Codeigniter [英] Rewrite URL Codeigniter
本文介绍了重写URL Codeigniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为我的Web应用程序使用Codeigniter,我将项目的结构更改如下:
i'm using Codeigniter for my web app, i changed the structure of the project as the following :
my_Project
--- application
--- public_html
--- resources
--- system
我创建了文件夹public_html来将我的公共文件与类..等分开,但是现在我每次必须调用此url:
I created the folder public_html to seperate my public files from the classes .. etc, but now i have to call this url every time :
my_project/public_html/controller/action
我希望这样:
my_project/controller/action
我已经使用重写模式从URL中移出了index.php,但我似乎也无法删除public_html:
I already moved out the index.php from the URL using the rewrite mode, but i can't seem to remove the public_html as well :
.htaccess
.htaccess
<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On
# If your website begins from a folder e.g localhost/my_project then
# you have to change it to: RewriteBase /my_project/
# If your site begins from the root e.g. example.local/ then
# let it as it is
RewriteBase /uca-flsh/public_html
# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)
# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|public|assets|css|js|images|resources|public_html)
# No rewriting
RewriteRule ^(.*)$ - [PT,L]
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>
.config.php
.config.php
$config['base_url'] = 'http://localhost/uca-flsh/public_html';
推荐答案
尝试使用此功能:
RewriteCond %{THE_REQUEST} /my_project/public_html/controller/action [NC]
RewriteRule ^ my_project/controller/action [L,R]
这篇关于重写URL Codeigniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文