• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
301 redirects in .htaccess file


Please ignore spaces in links - for some reason I'm not allowed to use them!

I have recently redesigned a website in CodeIgniter and would now like to be able to create 301 redirects from, for example, http:// www. somesite. com/ page.shtml?abc to http:// www. somesite. com/ xyz.

I read somewhere that using Redirect 301 lines weren't a good idea because of all the RewriteRule lines already in my .htaccess file - getting rid of index.php and ensuring www is used, etc.

So I am trying to redirect using this line, instead:
RewriteRule ^page.shtml?abc /xyz [R=301]

I continue to get a 404 with this, so I don't think the first part of this RewriteRule is correct.

I have tried moving the line to the top of the .htaccess file, so that the other RewriteRules aren't interfering, but I still get a 404.

Here is my .htaccess in full:
RewriteEngine on

#Use index.php
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|humans\.txt|sitemap\.xml)
RewriteRule ^(.*)$ index.php/$1 [L]

#Force www. prefix
RewriteCond %{HTTP_HOST} !^www. somesite\. com$ [NC]
RewriteRule ^(.*)$ http:// www. somesite. com/$1 [L,R=301]

#Permanent redirects
RewriteRule ^page.shtml?abc /xyz [R=301]

#This doesn't work, because RewriteRules are executed first
#Redirect 301 /page.shtml?abc http:// www. somesite. com/xyz

The rest of the RewriteRule lines work as expected; it's only the 301s I am having trouble with.

I would be very grateful if someone could help me find the solution.
Many thanks in advance.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.