2015-05-13 77 views
0

所以我必須像網址:http://localhost/folder_name/home笨:如何在CodeIgniter的URL刪除 '文件夾名稱'

我想刪除/從URL刪除'folder_name'所以我的網址變成http://localhost/home

我已經嘗試此代碼:

RewriteEngine On 
RewriteBase/

RewriteRule ^((?!folder_name/).*)$ folder_name/$1 [L,NC,R] 

此代碼讓我訪問的URL在http://localhost/home,但在瀏覽器每次經過我按ENTER鍵「的網址。 URL將變成http://localhost/folder_name/home

是否可以'永久刪除'文件夾名稱?

謝謝:)

+0

爲什麼不更改您的虛擬主機設置以將您的域直接指向您的文件夾名稱? – harrrrrrry

回答

2

也許FOLDER_NAME仍然在你的網頁瀏覽器記住,然後當你按下回車鍵,就自動完成舊的URL。

我認爲你應該嘗試從你的網絡瀏覽器中刪除cookies並重試。祝你好運!

+0

我已經清除了我的歷史記錄和Cookie,但每次我在網絡瀏覽器中啓動URL時,始終顯示folder_name,儘管我無法訪問文件夾名稱 – TableMan

-1

更新你的.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] 
+0

這不是工作夥計 – TableMan

0

考慮:

http://localhost/folder_name/home

答:如果您在使用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

一個&乙
3)在你的application/config/config.php文件...

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

只有B
4)做的:sudo service apache2 restart

注:
這就是我對我的htdocs/.htaccess一個/var/www/html/.htaccess(隱藏文件) ...

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 

希望這有助於!和平!

相關問題