Reputation: 11341
I want to create a .htaccess
file manually and discovered it seems impossible through the Windows UI. I get a "you must type a filename." message. There has to be a way to create files with .
as a prefix in Windows.
Can this be done manually?
Upvotes: 470
Views: 215980
Reputation: 139
in windows, you can also use cmd to create these type of file.
mkdir .htacess
Please verify if this file is created or not.
Upvotes: -3
Reputation: 101
Just type .htaccess.
as filename. Notice the dot at the end of htaccess. This will change in Windows to .htaccess
without a dot at the end.
Upvotes: 10
Reputation: 7701
You can use echo. > .gitignore
. This is how I achieved it to create .gitignore
:
C:\Users\jaimemontoya\[path]>dir
Volume in drive C is OS
Volume Serial Number is 2BD2-JQ68
Directory of C:\Users\jaimejaimemontoya\[path]
11/02/2021 02:42 AM <DIR> .
11/02/2021 02:42 AM <DIR> ..
11/05/2021 05:22 AM <DIR> .git
11/02/2021 02:41 AM <DIR> .gradle
11/02/2021 02:43 AM <DIR> .idea
11/02/2021 02:41 AM <DIR> app
11/02/2021 02:41 AM <DIR> build
..........
..........
12 File(s) 14,104 bytes
8 Dir(s) 231,501,361,152 bytes free
C:\Users\jaimemontoya\[path]>echo. > .gitignore
C:\Users\jaimemontoya\[path]>dir
Volume in drive C is OS
Volume Serial Number is 2BD2-JQ68
Directory of C:\Users\jaimemontoya\[path]
11/05/2021 05:40 AM <DIR> .
11/05/2021 05:40 AM <DIR> ..
11/05/2021 05:22 AM <DIR> .git
11/05/2021 05:40 AM 3 .gitignore
11/02/2021 02:41 AM <DIR> .gradle
11/02/2021 02:43 AM <DIR> .idea
11/02/2021 02:41 AM <DIR> app
11/02/2021 02:41 AM <DIR> build
..........
..........
13 File(s) 14,107 bytes
8 Dir(s) 231,512,551,424 bytes free
Upvotes: 0
Reputation: 4220
Windows 7, 8 & 10
This is dead easy since Windows 7. In File Explorer, right click anywhere and create a new file. Type the new filename as .something.
(notice the appended period) and press enter twice, job done.
So instead of being prompted with
You must type a file name.
You will instead be prompted with
If you change a file name extension, the file might become unusable.
Note: If you're having issues then please ensure you have "file name extensions" visible, you can activate this under the "View" menu in File Explorer. Also, this method works for folders too.
Upvotes: 308
Reputation: 2813
It seems that Microsoft finally is addressing this problem. Current versions in the Insider Editions of Explorer allows creating files with a dot at the front.
Tested with Build 19541
Upvotes: 2
Reputation: 508
Might sound unbelivable, but Windows 1903 finally allows to name files in Explorer with a leading dot :-)
Upvotes: 3
Reputation: 1558
In Windows, just go to the folder using cmd and type the following command:
DIR>.htaccess
This command will create a .htaccess
file and will dump some data in it.
Remove the data, and it can be used as .htaccess
file.
Upvotes: 2
Reputation: 450
As an addition, if have Sublime Text installed in your development computer, you can drag the file to your opened Sublime Text window, right click the filename -> rename and enter whatever name even without any extension. This worked for me.
Upvotes: 0
Reputation: 8616
Use something like Notepad++ (or even Notepad), 'Save As', and enter the name .htaccess that way. I always found it weird, but it lets you do it from a program!
Upvotes: 4
Reputation: 55489
You can save it using the Save As dialog using ".something".
Upvotes: 5
Reputation: 1819
If you use Git and have Git Bash installed you can open a Git Bash at the directory (via Right Click in the white space in Explorer > Git Bash Here) and do:
touch .htaccess
Upvotes: 0
Reputation: 4160
You could also use Command Prompt with move
: move x.extension .extension
Upvotes: 11
Reputation: 2173
Even if you don't have any third party editor (Notepad++ etc.) then also you can create files with dot as prefix.
To create .htaccess
file, first create htaccess.txt file with Context Menu > New Text Document
.
Then press Alt + D
(Windows 7) and Ctrl + C
to copy the path from the Address bar of Windows Explorer.
Then go to command line and type code as below to rename your file:
rename C:\path\to\htaccess.txt .htaccess
Now you have a blank .htaccess
without opening it in any editor.
Hope this helps you out.
Upvotes: 5
Reputation: 2098
Within Notepad select File > Save As...
File name: ".whatever you want"
(with the leading dot)
You can do it in Explorer (in Windows 7) by adding a period at the end of the filename:
.whatever you want.
Windows will automatically remove the trailing dot when you validate.
Upvotes: 90
Reputation: 8672
If you start Notepad and then File -> Save As -> Write .htaccess and choose "All Files" as the type - then it will create the .htaccess file for you.
Upvotes: 372
Reputation: 612954
You can do this in any program other than Explorer
, e.g. Notepad
, cmd.exe
etc.
You just can't do it in Explorer, and Raymond Chen has offered an explanation as to why not.
Upvotes: 9
Reputation: 740
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
Upvotes: 30