【问题标题】:htaccess with laravel 4 rewrite on my localhost URLhtaccess 与 laravel 4 重写我的本地主机 URL
【发布时间】:2014-01-10 19:40:28
【问题描述】:

我使用这个解决方案来解决我的 htaccess 问题:Htaccess redirect Laravel 4

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On

    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

非常好,但它重写了我的本地网址:localhost:8888/ => www.localhost:888/

我尝试添加:

RewriteCond %{HTTP_HOST} !=localhost [NC]
RewriteCond %{HTTP_HOST} !=127.0.0.1

但它不起作用 怎么办?

谢谢

【问题讨论】:

    标签: .htaccess mod-rewrite url-rewriting laravel laravel-4


    【解决方案1】:

    你可以试试:

    <IfModule mod_rewrite.c>
        Options -MultiViews
        RewriteEngine On
    
        RewriteCond %{HTTPS} off
        RewriteCond %{HTTP_HOST} !^www\. [NC]
        RewriteCond %{HTTP_HOST} !localhost [NC]
        RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
    
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    </IfModule>
    

    【讨论】:

    • 您好,感谢您的帮助,但它不起作用。 www 永远在这里。
    • OK 查看更新的代码并确保在新浏览器中进行测试以避免缓存问题。
    • 是的,我在新浏览器上测试过
    • 因为您可能有其他一些代码/框架/规则强制执行此操作。
    • 我的框架是Laravel 4,看不出来可以
    猜你喜欢
    • 2013-11-22
    • 1970-01-01
    • 2013-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-31
    • 1970-01-01
    • 2013-01-23
    相关资源
    最近更新 更多