【问题标题】:Laravel 4 htaccess redirect loop 2Laravel 4 htaccess 重定向循环 2
【发布时间】:2015-09-02 04:14:24
【问题描述】:

这是现在的 .htaccess 文件

 <IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
    Options -MultiViews
  </IfModule>

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

但我想更改此文件,因为当请求来自 blog.domain.com 时,它重定向到 /blog 文件夹和其他文件到 index.php

【问题讨论】:

  • 那么你使用了什么导致了循环?
  • 当我将 url 更改为 /blog

标签: php apache .htaccess mod-rewrite laravel-4


【解决方案1】:

试试这个:

RewriteEngine On
#Redirecting blog.example.com to blog folder
RewriteCond %{HTTP_HOST} ^blog.example.com$ [NC]
RewriteRule ^(.*)/?$ /blog/$1 [L,NC] 

#Redirect other requests to index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /index.php [L,NC]

【讨论】:

  • 当我输入“/”时它是否有效,它会将公共文件夹返回给我
  • “当我放 /”是什么意思?
  • 其实我也想访问public文件夹。
  • 我解决了这个问题,但它创建了一个新问题。当我把这个 domain.com 这样的 url 重定向到 domin.com/public/ 时,我该如何删除 public
  • 这可能是因为您的其他规则或浏览器缓存,清除您的浏览器缓存,看看是否解决问题。
猜你喜欢
  • 2013-11-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-11
  • 2013-07-17
  • 2017-10-10
  • 1970-01-01
相关资源
最近更新 更多