簡體   English   中英

使用.htaccess重寫URL?

[英]url rewriting using .htaccess?

我正在使用codeigniter。 有一個網址模式: localhost/mysite/application/assets/projects/projectname

projectname部分是動態的。 現在,我想將該網址重寫為: localhost/mysite/projectname

是否可以使用.htaccess 如果是的話,代碼是什么。

試試這個.htaccess

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond $1 !^(index\.php|indexcp\.php?|resources|robots\.txt)
RewriteRule ^([A-Za-z0-9_/.-]+)$ index.php?$1 

RewriteRule ^(CSI) index.php?/CSI
AddType text/x-component .htc

編輯

一旦嘗試這種方式

RewriteRule ^(/application/assets/projects)$ http://localhost/mysite/$1 [R,NC,L]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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