簡體   English   中英

CodeIgniter:如何在CodeIgniter URL中刪除“文件夾名稱”

[英]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中,這取決於您的發行版。

鑒於:

HTTP://本地主機/文件夾名/家

答:如果您正在使用XAMPP ...
1)在您的htdocs目錄中,將folder_name 所有內容轉移到htdocs目錄中。
->內容將包括: application folderassets folder等。

2)刪除文件夾folder_name

B.如果您使用的是LAMP ...
1)在/var/www/html/目錄中,將folder_name之外的所有內容轉移到/var/www/html/目錄中。
->內容將包括: application folderassets folder等。

2)刪除文件夾folder_name

A&B
3)在您的application / config / config.php文件中...

$config['base_url'] = 'http://localhost/';

僅B
4)做: sudo service apache2 restart

注意:
這是我的A的 htdocs/.htaccessB的 /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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM