Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use .htaccess file on an apache localhost server

Alright, I got an Apache localhost server up and running with PHP and MySql. Now I want to be able to use a .htaccess file as well to use RewriteRule, But I'm at a loss where to put it.

I have these directories:

C:\dev\progs where Apache PHP and MySQL are stored, each in their own sub-directories, ie. C:\dev\progs\Apache and so on...

C:\dev\www where all the site files are stored.

I need to know where to put the .htaccess file, what configuration I need to do, and if what I'm my hopes and dreams are all for nothing.

Thanks

like image 668
KFox Avatar asked Jan 23 '13 22:01

KFox


People also ask

Does .htaccess work on localhost?

A . htaccess file can be used to alter the configuration of the Apache to enable/disable additional functionality and features it offers. In order to make a . htaccess file for local host, you need to first enable it on apache servers.

Where do I put .htaccess file on server?

htaccess file location is most commonly found in your website's public_html folder. You can access your . htaccess file in a few different ways: From your hosting account's file management (such as via cPanel)


2 Answers

Enable .htaccess on apache servers in localhost

1) Find your apache directly which uses the php installation .
2) Open your httpd.conf  with notepad, Which is located in the path \apache\conf directory
3) Find the code like below       
      #LoadModule rewrite_module modules/mod_rewrite.so
4) Remove # from above code


# AllowOverride controls what directives may be placed in .htaccess files.
 # It can be "All", "None", or any combination of the keywords:
 #   Options FileInfo AuthConfig Limit
 #
 AllowOverride All   <--- make sure this is not set to "None"


5) Save httpd.conf file
6) Restart your apache server
like image 113
Gaurang P Avatar answered Sep 25 '22 01:09

Gaurang P


.htaccess is a configuration file that should be stored where your page is. In short, it should be in c:\dev\www in Your case, but You should read this too. BTW don't forget to turn on mod_rewrite by deleting a hash from the line where it resides

LoadModule rewrite_module modules/mod_rewrite.so

and enable .htaccess by changing

AllowOverride None

to

AllowOverride All
like image 39
Kitet Avatar answered Sep 24 '22 01:09

Kitet