Create a file with . dot prefix in Windows (.htaccess)


To totally unlock this section you need to Log-in


Login

Scenario

We want to create a .htaccess file manually and discovered it seems impossible through the Windows graphical interface. We get a You must type a filename. error message. There has to be a way to create files with . as a prefix in windows. Can this be done manually?

Create a file with . dot prefix in Windows (.htaccess)

Method 1 - Use Notepad Save As feature

You start Notepad and then File -> Save As -> .htaccess and choose "All Files" as the type - then it will create the .htaccess file for you.

Create a file with . dot prefix in Windows (.htaccess)

Method 2 (at least Windows 7)

You can do it in Windows Explorer (from Windows 7 and above) by adding a period at the end of the filename:

.whatever you want.

Windows will automatically remove the trailing dot when you validate (Windows will ask for a confirmation to the message "If you change a file name extension, the file might become unusable.").

Method 3 - Using command line

Go to command prompt, cd to the appropriate folder and type:

notepad .htaccess

After confirmation dialog the file will be created and you will be editing it directly. If you just want to create an empty file, try:

echo. > .htaccess