Problem with htaccess file

Hello, I made a few redirections in the htaccess file today, and they were working fine.
Then I made a few more, from my old RW blog to the new one I’m making with the Poster stack.
The redirections didn’t seem to work, so I tried to re-open the htaccess file in RW, and RW crashed as soon as I clicked on the button. I tried many times, rebooted, etc. and it still crashes.
Then I tried to open the file with TextEdit, using Transmit, I erased the last lines that I had added before the crashes, and RW still crashes as soon as I try to open the file from RW.
Any idea?

I have finally been able to re-open it, but there seem to be a problem with those lines I had added.

How did you add the lines? Copy and paste? Htaccess files are really fussy about being plain text.

Other than that without seeing the file in question it’s difficult to say.

TextEdit is a very poor “plain text” editor, it’s capable of doing plain text but it doesn’t default to that.

You can also test your redirects prior to putting them live in the htaccess file here:

1 Like

OK thanks I’ll try this tomorrow!
Good to know this about TextEdit, I used because I didn’t know better. I also prepared my redirections with it, but it didn’t seem to matter with the first series of links.
Maybe I should have used “paste as plain text” in the RW menu!?
Thanks a lot for the infos!

I tried to reproduce this and found that if I create a new publishing destination as Local Folder and leave all fields empty and then click on the “Edit .htaccess File” button, RW crashes.

So maybe worth checking your publishing settings?

I tried to use this tool, but I’m not certain I got it right.

I’m trying to redirect a few links from an old part of my site, and there’s a problem that seems to be caused by the fact that some pages are on the submenu.
If you look at the secondary menu here, “Soul Vaccination” and “Soul with a Capital S” are redirected just fine, but I can’t seem to be able to redirect the submenu of “Soul with a Capital S part 2”. Clicking on the sub-menu “part 2” leads to and empty page.

Is there something that I don’t know about redirection of pages that are on sub-menus?
Here is what I entered, and this one works fine:
Redirect 301 /workshop/en/199801/ Soul with a Capital "S" - part 1
Then for the Part 2 sub-menu, and it doesn’t work:
Redirect 301 /workshop/en/199801/199802/ Soul with a Capital "S" - part 2
Clicking on the Part 2 sub-menu creates an url that opens an empty page (made of the target for the first level, and it adds the name of the folder at the second level).

Kinda difficult to say what might without seeing the entire htaccess file but I just ran a simple test with the following:

Redirect 301 /workshop/en/199801/
Redirect 301 /workshop/en/199801/199802/

This URL:
Should be redirecting to here:

Redirect Rules usually get applied in a “top down” order, so without seeing the entire htaccess file it’s difficult to say what might be going wrong. Also 301 redirect have no expiry date so they are very cache-able so a “typo”. An hang around for quite a while.

1 Like

On way to work on your htaccess file is to use a good code editor (I use BBedit) in conjuction with a an ftp app. Using ftp download the htaccess file to you Mac then use BBedit (or similar) to edit. SAVE A COPY OF THE ORIGINAL. When done editing the file upload it to your server with ftp app. If things go wring simply revert back to the original until you figure things out.

I should mention that your Mac won’t show a file that begins with a period so I actually duplicate the file on the server (giving me yet another copy) and change the period to an underscore. After editing and uploading rename with the period.

1 Like

Yes, that’s what I entered in the htaccess file, but then it leads to this page that I never created:
I think I’m about to give up…

The first thing I would do is remove those rules immediately from the htaccess file. As I said in the earlier post 301 redirects are permanent and are eligible to be cached forever. That means any proxy server(like most businesses and search engines) may never come back to the old URL.

Second I would remove the 301 while testing. Once you’re sure everything is redirecting to the correct page then re-add the 301 and retest.

I’m not at a Mac right now but it looks like might b picking up sub directory for some reason. I’ll be back at my office in a couple hours and can have a look later if you don’t get it figured out by then.

1 Like

I think using an Alias (single lin) rewrite rule with a Query string(stuff after the ?) seems to be the issue. I would probably use a full mod_rewrite rule set instead.
I just ran a quick test (with the tester above), and the Alias style doesn’t produce the correct “Output URL” on the page.

The following full mod_rewrite should work:

RewriteEngine on
RewriteCond %{REQUEST_URI} /workshop/en/199801/199802/$ [NC]
RewriteRule ^(.*)$ [R=302,L]
RewriteCond %{REQUEST_URI} /workshop/en/199801/$ [NC]
RewriteRule ^(.*)$ [R=302,L]

I have set this up as a temporary redirect (r=302), so you can test without worrying about caching.

Once you have tested then just change the two [R=302,L] to [R=301,L] to make them permanent.


Wow! That’s so cool, it works perfectly! It’s so much beyond my knowledge, thanks a lot for taking the time to help me!

1 Like

Thanks for the info!

Now that the redirections work, when trying to open the htaccess file in RW, RW crashes again.

Maybe I included some formatting, although I used an application that’s meant to remove all formatting. Could it be the reason?

I installed TextWrangler, I guess it is an alternative to Bbedit!? I plan to download the file from the server with Transmit, and make an all new htaccess file with its contents plus the new redirections. Would it be a good idea?

text Wangler should work fine for plain text (until the next macOS comes out). I think I have almost every text editor there is. The important thing for htaccess files is they produce “plain text”.

I haven’t really used the new “Built-in” htaccess editor much yet, It looks like it is good, So I don’t know why RapidWeaver would crash on you. I’ve always used a “plain text editor” and Transmit to handle htaccess files.

Text Wrangler is 32bit and they say won’t be upgraded so it will more than likely stop working with 10.15.x (this fall).

BBEdit (text wranglers big brother) is a great old school text editor but might be overkill for just minor text changes. Most of the really good editors do a lot of stuff like autocomplete and highlighting for various languages.

I keep a simple text editor called TextPad on my dock, It doesn’t do much of anything but edit plain text. I think it was 99 cents on the app store.


Should the “RewriteEngine on” command be entered before the first line, even if it was already present on the page before?

I only used this full “mod_rewrite” for the links that didn’t work previously. Or do you think I should also use this mode for all the links in the same series?

I guess that in the future I should always first use the “Redirect 302” mode when testing any redirection, right?

This directive only needs to be in the htaccess file once. It should be prior to the mod_rewriterules. I usually put it up at the top.

The alias Redirects (single line) are fine if they work. They just aren’t as flexible. So as long as they work you can leave them.

302’s are much safer and easier to test. They aren’t cached so testing changes is instant. I would use a “test script” and retest after changing them to 301’s just to make sure you don’t have any typos.

1 Like

I had put the “RewriteEngine on” command once before the first redirects I made, but I noticed it is present on the page three times now, which means it was there twice already on the initial htaccess file.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.