[英]Remove Subfolder[Codeigniter] only for specified URLs using Htaccess
[英]htaccess specified in codeigniter
我在codeigniter中的.htaccess中有问题
如果我删除index.php,它将产生错误没有指定输入文件,并且我的URL是http://cg.alpcube.com/index.php/home/register
我的.htaccess文件如下
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1
如何从网址中删除index.php
在您的codeigniter文件夹上,添加.htaccess
并添加它
RewriteEngine on
RewriteCond $1 !^(index\.php)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
假设您的项目名称是Example现在在项目文件夹中将有一个文件.htaccess
<ifModule mod_rewrite.c>
# Turn on the engine:
RewriteEngine on
# Don't perform redirects for files and directories that exist:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# For everything else, redirect to index.php:
RewriteRule ^(.*)$ index.php/$1
</ifModule>
将此写入.htaccess文件
现在只需运行此命令
sudo a2enmod rewrite
然后重新启动您的Web服务器
sudo service apache2 restart
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
将其添加到必须位于项目根目录的.htaccess中:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.