Web Hosting Forum | Lunarpages

Author Topic: how to create a .htaccess file from scratch  (Read 2342 times)

Offline sher777

  • Trekkie
  • **
  • Posts: 16
how to create a .htaccess file from scratch
« on: September 08, 2016, 03:00:42 PM »
I am a novice in this area.  I was attempting to edit the .htaccess file to use Gzip and discovered there is no .htaccess file.  so I guess I need to create one. Can anyone point me in the right directions of links of tutorials?

I would like to use the "Weboptima" available in the LPCP.  When I attempted today to use the "Gzip/Deflate", I got an error
"Coldn't rename file from '/home/perla2/public_html/.htaccess' to '/home/perla2/public_html/.htaccess.bak.1473375459'"
I guess not if no file exists in the first place.

So also, any insight on using Weboptima would be appreciated.  Thank you!

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6197
Re: how to create a .htaccess file from scratch
« Reply #1 on: September 08, 2016, 03:29:14 PM »
It's trying to rename the existing .htaccess to a backup file. Did you change any directory or file permissions in the public_html directory or the .htaccess file? I believe that public_html/ is normally 750 and .htaccess is normally 644. If you made either of them unwritable (read-only), that might prevent the renaming.
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline sher777

  • Trekkie
  • **
  • Posts: 16
Re: how to create a .htaccess file from scratch
« Reply #2 on: September 08, 2016, 03:48:21 PM »
Hi MrPhil,
you were helping on the other forum how to access hidden files in LPCP.  The helpdesk replied that LPCP in filemanager does not hide any files.  He also said if I didn't see it, there is no htaccess file.
I looked.  I also did a search.  It's not there.
So I guess I have to create one from scratch?

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6197
Re: how to create a .htaccess file from scratch
« Reply #3 on: September 08, 2016, 07:32:13 PM »
That puzzles me... there should always be an .htaccess file, even an empty one, for an Apache server. On my cPanel server, if I erase .htaccess, it will create a new empty one (last time I tried). Your system may be trying to rename the old (existing) one, and failing because it doesn't exist. I suspect that something is broken on your server, and the support guy is just reading from a script and has never encountered such a thing. You might want to try escalating the matter to a supervisor, as I don't think things are working correctly. If the supervisor says that not having an .htaccess file is fine; that's something new.

Anyway, there are at least two ways around this. 1)  cPanel File Manager allows you to create a new (empty) file, so I'd be surprised if LPCP doesn't have some function like that in its File Manager, or 2) create .htaccess on your PC and upload it to your server, using the File Manager file upload function. You might have to name it something else, such as ht.txt, and then rename it (using the File Manager) after uploading it.
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline sher777

  • Trekkie
  • **
  • Posts: 16
Re: how to create a .htaccess file from scratch
« Reply #4 on: September 09, 2016, 09:12:27 AM »
Thank you MrPhil! This is exactly what LP helpdesk sent to me:
"Please note there is no option for "hidden files" in LPCP. By default all files are shown in LPCP. If you have .htaccess file then it will show. It is possible .htaccess file is not there as yet and you will need to create one."

It does seem odd so I did write back just to confirm.  I am going to try your instructions for creating a .htaccess file.

Offline sher777

  • Trekkie
  • **
  • Posts: 16
Re: how to create a .htaccess file from scratch
« Reply #5 on: September 09, 2016, 09:48:52 AM »
Update:
I created the .htaccess file successfully and proceeded to implement "weboptima".  Why not?
I have not read anywhere of anyone using this, but for a novice like me and saving time.  Here's what happened...
my website did not crash and disappear as I feared.  :happy:
and I went back and tested my page speed with https://developers.google.com/speed/pagespeed
it went from 57 to 64  :yep:
still slow but better.

Thank you MrPhil!

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6197
Re: how to create a .htaccess file from scratch
« Reply #6 on: September 09, 2016, 10:51:33 AM »
Good to hear things are working now!
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

 

Share |