codeigniter - .htaccess not redirecting from old url to new url -


i have developed website using codeigniter. site had long url structure have made them shorter in new website.

although used redirect directive in htaccess gives me 404 error. have removed old controllers , functions.

below few lines htaccess (there many urls redirecting new ones)

rewriteengine on  # redirect non-www urls www  rewritecond %{http_host} ^mysite\.com [nc] rewriterule (.*) http://www.mysite.com/$1 [r=301,l]   #rewriterule ^([^_]*)_(.*)$ /$1-$2 [r=301,l]   rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ /index.php?/$1 [l]  redirect 301 /payments/charity_and_donations/paid http://www.mysite.com/charity redirect 301 /outwards/office_furniture/damaged http://www.mysite.com/office_assets redirect 301 /funding/business_and_person/inward http://www.mysite.com/funds 

can tell me why not redirecting old new , doing wrong?

you need have redirecting happen before route uris /index.php. also, since redirect part of mod_alias , other redirect/routing rule mod_rewrite, uri being processed twice when it's not supposed to. should use mod_rewrite , add rules beginning:

rewriteengine on  # redirect non-www urls www rewritecond %{http_host} ^mysite\.com [nc] rewriterule (.*) http://www.mysite.com/$1 [r=301,l]   rewriterule ^payments/charity_and_donations/paid http://www.mysite.com/charity [r=301,l] rewriterule ^outwards/office_furniture/damaged http://www.mysite.com/office_assets [r=301,l] rewriterule ^funding/business_and_person/inward http://www.mysite.com/funds [r=301,l]  rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ /index.php?/$1 [l] 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -