如何手动创建带有 . Windows 中的(点)前缀?例如,.htaccess

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5004633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 08:04:20  来源:igfitidea点击:

How do I manually create a file with a . (dot) prefix in Windows? For example, .htaccess

windows.htaccesswindows-xpfilenames

提问by Doug Chamberlain

I want to create a .htaccessfile 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.

我想.htaccess手动创建一个文件,但发现通过 Windows UI 似乎不可能。我得到一个“你必须输入一个文件名”。信息。必须有一种方法可以.在 Windows 中创建带有前缀的文件。

Can this be done manually?

这可以手动完成吗?

Enter image description here

在此处输入图片说明

采纳答案by foens

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.

如果您启动记事本,然后文件 -> 另存为 -> 写入 .htaccess 并选择“所有文件”作为类型 - 那么它将为您创建 .htaccess 文件。

Notepad save as .htaccess

记事本另存为 .htaccess

回答by Matt Kieran

Windows 7, 8 & 10

视窗 7、8 和 10

This is dead easysince 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.

从 Windows 7 开始,这很容易。在文件资源管理器中,右键单击任意位置并创建一个新文件。键入新文件名.something.(注意附加的句点)并按两次 Enter,工作完成。

Demonstrating how to create a file with no name in File Explorer.

演示如何在文件资源管理器中创建没有名称的文件。

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.

如果更改文件扩展名,该文件可能变得不可用。

回答by dhirschl

Within Notepad select File> Save As...

在记事本中选择File>Save As...

File name: ".whatever you want"(with the leading dot)

文件名:(".whatever you want"带前导点)

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

您可以通过在文件名末尾添加句点在资源管理器(在 Windows 7 中)中执行此操作:

.whatever you want.

.whatever you want.

Windows will automatically remove the trailing dot when you validate.

当您验证时,Windows 将自动删除尾随点。

回答by Boocko

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

转到命令提示符,cd 到相应的文件夹并键入:

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

回答by Nikoloff

You could also use Command Prompt with move: move x.extension .extension

您还可以使用命令提示符movemove x.extension .extension

回答by David Heffernan

You can do this in any program other than Explorer, e.g. Notepad, cmd.exeetc.

您可以在任何程序比其他为此Explorer,例如Notepadcmd.exe等等。

You just can't do it in Explorer, and Raymond Chen has offered an explanation as to why not.

你不能在 Explorer 中做到这一点,而 Raymond Chen 已经解释了为什么不这样做

回答by Hymany

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.

只需输入 .htaccess。作为文件名。注意 htaccess 末尾的点。这将在 Windows 中更改为 .htaccess,最后没有点。

回答by Sachin Shanbhag

You can save it using the Save Asdialog using ".something".

您可以使用“ .something”使用“另存为”对话框保存它。

回答by Brian

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!

使用Notepad++(甚至Notepad)、“另存为”之类的东西,然后以这种方式输入名称 .htaccess。我总是觉得它很奇怪,但它可以让你从程序中做到这一点!

回答by Vicky Dev

Even if you don't have any third party editor (Notepad++ etc.) then also you can create files with dot as prefix.

即使您没有任何第三方编辑器(Notepad++ 等),您也可以创建以点为前缀的文件。

To create .htaccessfile, first create htaccess.txt file with Context Menu > New Text Document.

要创建.htaccess文件,首先创建 htaccess.txt 文件Context Menu > New Text Document

Then press Alt + D(Windows 7) and Ctrl + Cto copy the path from the Address bar of Windows Explorer.

然后按Alt + D(Windows 7) 和Ctrl + C从 Windows 资源管理器的地址栏中复制路径。

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 .htaccesswithout opening it in any editor.

现在您有一个空白,.htaccess无需在任何编辑器中打开它。

Hope this helps you out.

希望这可以帮助你。