Michael Rogers
Michael Rogers

Reputation: 233

.htaccess 500 internal server error when adding simple 301 redirect

This is driving me crazy.

Long story short i can't change anything on my .htaccess because it generates a 500 Internal server error.

Some days ago i noticed something weird, some of the files on my server .htaccess included starting to show with line breaks between each line, or the whole code in 1 long line which caused thing breaking on the site.

Now whenever i try to add something simple to .htaccess like a 301 redirect: Redirect 301 /random-file.html http://dumbsite.com/section/random-file.html

It gives me a 500 Internal server error, i know this happens when you do things wrong but i'm 100% sure my rule is correct.

My theory is that it has something to do with notepad++ of filezilla. So the question is: On notepad++ what encoding or settings do i need to have or not have to avoid this.

And also if Filezilla is the cause, should i use Binary or ASCII or Auto transfer method and should i leave "Thread dotfiles as ASCII" ticked or not on transfer settings. I've tried every combination and no matter what it gives me the 500 Internal server error.

So maybe there's more than 1 thing wrong.

UPDATE! Ok, i've been debuging this. and i can confirm the error comes from Notepad++ I've reseted to defaults both filezilla and notepad++ and the error still happened. So i choose to edit the file with regular notepad added my 301 redirect and boom it worked! So filezilla is OK. My 301 is OK and working.

The problem relies on the format notepad++ is using to save the .htaccess file. So if anyone could tell me what settings you use to generate a functional .htaccess file with notepad++ i'm all set.

Upvotes: 0

Views: 1682

Answers (3)

ravina vala
ravina vala

Reputation: 129

Please try this:

301 redirect

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    Redirect 301 /our_clients/nike /project/nike-nofyme-campaigns
</IfModule>

Upvotes: 1

TrtG
TrtG

Reputation: 2848

Have you tried to check the line breaks configuration from notepad? Because if you edit your code on windows with windows format line breaks and then just put it as is on a Linux server it won't work. You can convert them to unix format in notepad edition menu.

Upvotes: 0

ehmad11
ehmad11

Reputation: 1395

It's probably because of filezilla default transfer mode, you have to set it to 'binary'

go to edit > settings > transfers > filetypes and set default transfer mode to binary

check this too http://domaze.net/watch?v=yEn7iZmXELI

Upvotes: 0

Related Questions