简体   繁体   English

在运行时更改URL(即重写URL)

[英]Change url on runtime (i.e. rewrite url)

I want to rewrite my website url through the htaccess, currently my project made in YII, i want to change my url on runtime. 我想通过htaccess重写我的网站URL,目前我的项目是在YII中完成的,我想在运行时更改我的URL。

currently this is not on live server, this is on my local server and my current password is 当前这不在活动服务器上,这在我的本地服务器上,我当前的密码是

localhost/pecb_new/trunk/admin/apps/backend/site/login

and i want to change it to 我想将其更改为

localhost/pecb_new/trunk/admin/site/login

ie change admin/apps/backend/ from url to the admin/ , please if some one has answer of this question then provide me the answer. 即将admin / apps / backend /从url更改为admin/ ,如果有人对此问题有答案,请给我答案。

Try putting these rules in the htaccess file in the /trunk/admin/ directory: 尝试将这些规则放在/trunk/admin/目录的htaccess文件中:

RewriteEngine On

RewriteCond %{THE_REQUEST} \ /+trunk/admin/apps/backend/([^\ \?]+)
RewriteRule ^ /%1 [L,R]

RewriteCond %{DOCUMENT_ROOT}/trunk/admin/apps/backend/$1 -f [OR]
RewriteCond %{DOCUMENT_ROOT}/trunk/admin/apps/backend/$1 -d
RewriteRule ^(.*)$ /trunk/admin/apps/backend/$1 [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM