Mohib
Mohib

Reputation: 175

Laravel 4 htaccess redirect loop 2

this is the .htaccess file now

 <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]

But i want to change this file as when request come from blog.domain.com it redirect to the /blog folder and other file to the index.php

Upvotes: 2

Views: 94

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

Try this :

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]

Upvotes: 1

Related Questions