Evgeni Vasilev
Evgeni Vasilev

Reputation: 11

FastCGI .htaccess redirect not working

I'm developing a PHP, MVC, web app on a server with fastcgi. Because of the fastCGI I had to use question mark in my RewriteRule like that:

RewriteRule ^(.*)$ index.php?/$1 [L] 

but then when I try to do a simple 301 redirect I end up redirected to an awkward url like this: http://example.com/bg/home/login?/admin

My .htaccess looks like this:

RewriteEngine On
DirectoryIndex index.php

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Redirect 301 /admin /bg/home/login

Any ideas on how to do the 301 redirects properly?

Upvotes: 1

Views: 738

Answers (1)

umka
umka

Reputation: 1655

You should add an exception for this URI after last RewriteCond:

RewriteCond %{REQUEST_URI} !^/bg/home/login$

If you want to get rid of query string, the better way is to make it using RewriteRule instead of Redirect. Add before first RewriteCond:

RewriteRule ^admin$ /bg/home/login? [R=301,L]

Upvotes: 0

Related Questions