我在Yii2應用.htaccess的URL重寫Yii2應用
http://127.0.0.1/frontend/web/index.php?r=site%2Flogin
http://127.0.0.1/frontend/web/index.php?r=site%2Fpage2
http://127.0.0.1/frontend/web/index.php?r=site%2Fsample
http://127.0.0.1/frontend/web/index.php?r=site%2Fsignup
以下網址結構我怎麼能轉換這個URL類似
http://127.0.0.1/login.php
http://127.0.0.1/page2.php
http://127.0.0.1/sample.php
http://127.0.0.1/signup.php
我應該刪除frontend/web/index.php?r=site%2F
我嘗試過,但它不起作用
Options -Multiviews
RewriteEngine On
RewriteBase/
# Force search engines to use http://127.0.0.1/frontend/web/
RewriteCond %{HTTP_HOST} !^http://127\.0\.0\.1/frontend/web/$
RewriteRule ^(.*) http://127.0.0.1/frontend/web/$1 [R=301,L]
# Specify search friendly URLs
RewriteRule ^login\.php$ /index.php?r=site%2Flogin [L]
我也試過了,它也沒有工作。
RewriteEngine on
RewriteRule ^frontend/web/index.php?r=site%2F([^\./]+) /$1.php [L]
你想在全局中添加'.php'後綴還是僅僅爲'SiteController'操作? – arogachev 2015-02-12 09:39:53
@arogachev - 全局通過htaccess – lock 2015-02-12 09:40:29
而您想爲'SiteController'操作移除'site',對吧? – arogachev 2015-02-12 09:41:11