htaccess redirect 301 single url |
[eluser]ironlung[/eluser]
Hi all I have the normal htaccess file for codeigniter and I want to 301 one url to another ie http://www.domain.com/controller/method/value1 ->http://www.domain.com/controller/method/value2 but I'm having a hell of a time... Here's the htaccess Code: <IfModule mod_rewrite.c>
[eluser]ironlung[/eluser]
If I do this Code: Redirect 301 /controller/method/value1 http://www.domain.com/controller/method/value2 I get this Code: http://www.domain.com/controller/method/value2?controller/method/value1 which is whacky doodle dandy ![]() Edited to put missing leading slash in.
[eluser]Aken[/eluser]
Try putting a slash at the start of your matched url, e.g.: Code: Redirect 301 /controller/method/value1 http://www.domain.com/controller/method/value2
[eluser]ironlung[/eluser]
[quote author="Aken" date="1363135495"]Try putting a slash at the start of your matched url, e.g.: Code: Redirect 301 /controller/method/value1 http://www.domain.com/controller/method/value2 Damn there is a slash I made a copy paste error!
[eluser]ironlung[/eluser]
Also tried this http://stackoverflow.com/questions/14517...r-htaccess ie. Code: RewriteRule ^/controller/method/value1$ /controller/method/value2 [R=301,L] Just redirects to homepage ![]() I lose days of my life everytime I open this file ![]()
[eluser]ironlung[/eluser]
[quote author="TheFuzzy0ne" date="1363163805"]Please could you post the whole file again?[/quote] Sure I'm just changing the domain name... Code: <IfModule mod_rewrite.c>
[eluser]TheFuzzy0ne[/eluser]
Is this where you're stuck? Code: RewriteRule ^(home(/index)?)/?$ / [L,R=301] First of all, I would suggest you replace: Code: RewriteCond %{HTTP_HOST} ^domain\.es [NC] with a more generic: Code: RewriteCond %{HTTP_HOST} !^www\. The next thing that glares at me is that you have this: Code: RewriteCond %{REQUEST_URI} ^system.* Your rewrite rule for both should probably be either: Code: RewriteRule ^(.*)$ index.php?/$1 [L] In theory, only one of those should actually work.
[eluser]ironlung[/eluser]
Hey thanks for helping. This worked great Quote: With these the first one put me on the 404 page second one gave me an internal server error (I did of course replace the text you suggested) Quote: My real issue is that I cant make a single one page 301 redirect Code: Redirect 301 /controller/method/value1 http://www.domain.com/controller/method/value2 gives me this Code: http://www.domain.com/controller/method/value2?controller/method/value1 ie it query strings the first url... So weird.
[eluser]TheFuzzy0ne[/eluser]
Does this not work? Code: RewriteCond %{REQUEST_URI} ^(/controller/method/value1) |
Welcome Guest, Not a member yet? Register Sign In |