我已阅读有关此事的帖子,但没有回答我的问题 我已经设置了我在代码点火器和SO的问题论坛上找到的一切
目前我有以下设置: .htaccess文件
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
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
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|(.*)\.swf|images|robots\.txt|css|docs|cache)
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.
ErrorDocument 404 /application/errors/404.php
</IfModule>
我也设置了$config['index_page'] = '';
但这不起作用,URL没有变化 如果我输入* http:// localhost:8088 / crud_demo / index.php / login *它可以工作但如果我输入* http:// localhost:8088 / crud_demo / login *它显示Not Found Error
我的路线配置
$route['register'] = "register";
$route['manage'] = "manage";
$route['default_controller'] = "login";
$route['404_override'] = '';
答案 0 :(得分:1)
在ubuntu中/etc/apache2/sites-available/000-default.conf
的虚拟主机文件中将AllowOverride None更改为AllowOverride All
在Windows中/etc/apache2/sites-available/default.conf
的虚拟主机文件中将AllowOverride None更改为AllowOverride All
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All <---- replace None with All
</Directory>
<Directory /var/www >
Options Indexes FollowSymLinks MultiViews
AllowOverride All <--- replace None with All
Order allow,deny
allow from all
</Directory>
....
然后将此代码放在codeigniter
的根文件夹中的.htaccess文件中RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
它肯定会起作用。
答案 1 :(得分:0)
RewriteRule ^crud_demo/(.*)$ crud_demo/index.php/$1
http://martinmelin.se/rewrite-rule-tester/来测试网址重写。
我认为CodeIgniter有自己的方式来路由URL,就像其他PHP框架一样。看看这里:http://codeigniter.com/user_guide/general/routing.html
答案 2 :(得分:0)
如果crud_demo是根目录的子文件夹,那么您应该更改
RewriteBase /
到
RewriteBase /crud_demo