How do I rename a file to .htaccess in Windows 7?

I'm using XAMPP to test a PHP script. Now, in the root of the folder I want to place a .htaccess file according to the requirements of the script.

But Windows won't let me rename it to .htaccess. Is there any way to go around it?

I'm using Windows 7 RTM.


Solution 1:

this link discusses the same problem on XP.

I'll let you read it and decide if it applies to Windows 7, but the solution involves using a command line.

EDIT:

It starts from the fact that Windows will let you create an htaccess.txt file
Then

Start Run > cmd

then type

rename c:\pathtoyourhtaccessfile\htaccess.txt .htaccess

will do the trick

Solution 2:

Thanks to https://serverfault.com/questions/22626/rename-files-to-empty-filename-in-windows-vista I learned a new trick. Since this page shows up in Google higher for that error message, I thought I'd link it here too.

Essentially if you want to do it in Explorer, name it .htaccess. with a trailing dot. The trailing dot tells Windows what the extension should be, and the initial dot and letters tell it what the filename (without extension) should be. It appears that a file without an extension is permissible, but not one without a filename. Fortunately, a file without an extension requires no dot, so we get the deletion that creates the filename we wanted (which is just an extension - see the filetype that Windows reports?)

You can do this with any string, not just htaccess. It makes a little sense to me because files that start with a dot have special meaning.