Home » Questions » Computers [ Ask a new question ]

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

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.

Asked by: Guest | Views: 331
Total answers/comments: 4
bert [Entry]

"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"
bert [Entry]

"Don't create the file in Windows Explorer. Create it in whatever program you are using (notepad, vim, eclipse whatever). Then select ""Save As"" and make sure ""All Files"" is selected. Type in .htaccess . It should work.

The All Files is to prevent the program automatically adding a file type extension (e.g. .htaccess.txt)"
bert [Entry]

Simply name it .htaccess. The ending dot will be automatically removed by Windows, leaving it named .htaccess as it should be.
Simply name it .htaccess. The ending dot will be automatically removed by Windows, leaving it named .htaccess as it should be.
bert [Entry]

"The official (i.e. non-hacky) way to bypass Windows filename limitations is to use the special CMD prefix \\?\ followed by the absolute (i.e. full) path to the file.

This prefix and the related form \\.\ allow you to bypass use of the Windows API directly, and can also be used in the same way to get around other Windows filename limitations such as maximum length (useful for deleting files whose paths are too long to be deleted normally).

To rename a file to .htaccess, simply run the following in a command prompt:

rename ""\\?\B:\Users\Me\Desktop\TEST.txt"" "".htaccess""

Note that the full path to the file is necessary - because the \\?\ syntax sidesteps the Windows API itself, it loses the ability to resolve relative path names, so an absolute path is needed for it to know where the file is."