![](/img/trans.png)
[英]How to remove folder name controller name and method name for url in codeigniter
[英]CodeIgniter : How to remove 'folder name' in CodeIgniter URL
所以我有URL Like: http:// localhost / folder_name / home
我想从URL中删除/删除'folder_name'
,因此我的URL变为http://localhost/home
。
我已经尝试过此代码:
RewriteEngine On
RewriteBase /
RewriteRule ^((?!folder_name/).*)$ folder_name/$1 [L,NC,R]
这段代码使我可以访问http:// localhost / home中的URL,但是每次我在“按Enter”后在浏览器中访问URL。 该URL将再次变为http://localhost/folder_name/home
是否可以“永久删除”文件夹名称?
谢谢 :)
也许仍然在您的Web浏览器中记住了folder_name,然后当您按下Enter键时,它会自动完成旧的URL。
我认为您应该尝试从网络浏览器中删除Cookie,然后重试。 祝你好运!
尝试使用虚拟主机更加灵活,您甚至可以设置自己的URL,例如myapp.dev
。
参考此信息:
视窗:
http://en.kioskea.net/faq/8485-configuring-apache-and-windows-to-create-a-virtual-host
在Linux中,这取决于您的发行版。
鉴于:
答:如果您正在使用XAMPP ...
1)在您的htdocs
目录中,将folder_name
所有内容转移到htdocs目录中。
->内容将包括: application folder
, assets folder
等。
2)删除文件夹folder_name
。
B.如果您使用的是LAMP ...
1)在/var/www/html/
目录中,将folder_name
之外的所有内容转移到/var/www/html/
目录中。
->内容将包括: application folder
, assets folder
等。
2)删除文件夹folder_name
。
A&B
3)在您的application / config / config.php文件中...
$config['base_url'] = 'http://localhost/';
仅B
4)做: sudo service apache2 restart
注意:
这是我的A的 htdocs/.htaccess
和B的 /var/www/html/.htaccess
(隐藏文件)的文件。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
希望这可以帮助! 和平!
更新您的.htaccess
RewriteEngine on
RewriteBase /home/
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.