Chintan Gor
Chintan Gor

Reputation: 1072

301 redirection in CodeIgniter having ? issue

Options +FollowSymlinks
RewriteEngine on

RewriteCond $1 !^(index\.php|assets|uploads|tt|application/modules/.*/assets|resources|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php?/$1 [L]    

Redirect 301 /testurl /home/ 

This is my .htaccess file for checking 301 redirection in my CodeIgniter project.

The 301 redirection works fine but problem is with the URL. When I try...

http://parcmobilenew.eworkdemo.com/testurl

...it redirects to Home Page as mentioned in .htaccess but it takes requested URL in query string like this...

http://parcmobilenew.eworkdemo.com/home?/testurl

How can I make the .htaccess not do this when redirecting?

Upvotes: 4

Views: 1123

Answers (1)

anubhava
anubhava

Reputation: 785196

  • Don't mix Redirect rules with mod_alias ones.
  • Keep redirect rules before internal rewrite ones.

You can use this code:

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^testurl/?$ /home/? [L,NC,R=301]

RewriteCond $1 !^(index\.php|assets|uploads|tt|application/modules/.*/assets|resources|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]

Better to test in a new browser to avoid old 301 caches.

Upvotes: 3

Related Questions