關於 Apache 的.htaccess 問題
阿神
阿神 2017-05-16 17:00:24
0
1
539

大家好!我目前的需求是: 當輸入的url 位址為http://www.lazyer.com/lazyer/frontend/web/site/login 時,強制重定向為http://www.lazyer.com/site/login 。為此,我在伺服器根目錄中寫了一個.htaccess 文件,裡面的程式碼如下:

<IfModule mod_rewrite.c>
    RewriteEngine On 
    RewriteBase / 

    RewriteCond %{HTTP_HOST} ^www\.lazyer\.com$
    RewriteCond %{REQUEST_URI} ^/lazyer/frontend/web/
    RewriteRule ^lazyer/frontend/web/(.*)$ http://www.lazyer.com/ [L,R=301]

</IfModule>

apache 也開啟了 rewrite 功能,但當輸入http://www.lazyer.com/lazyer/frontend/web/site/login時,卻沒有重定向的效果。請問是怎麼回事?

阿神
阿神

闭关修行中......

全部回覆(1)
漂亮男人

你URL裡的Lazyer首字母是大寫吧?規則裡用的是少寫。

建議你先寫個絕對能符合的規則,來驗證設定是否有效。如:
RewriteRule .* http:://segmentfault.com [R,NC]

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!