Laravel 4 htaccess重定向循环2

时间:2015-06-17 05:25:02

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

现在是.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

1 个答案:

答案 0 :(得分: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]