Is anyway to run .htaccess file in local server without using online?
I'm not sure whether I understand your question, but yes, you can use .htaccess
files in any Apache installation, whether that Apache runs on the internet or locally.
A .htaccess file is a means to configure a webserver on the fly, and without needing access to the global configuration files.
Since all it does is configure a server, it doesn't make sense for it to be involved without there being networking (even if only localhost to localhost networking) involved.
.htaccess
file is never being "run". It is merely a config file. Unnecessary one, as every it's command can be used in the main httpd.conf
config file.
what is the background led you to this question?
to make this file enabled, AllowOverride All
setting in the httpd.conf
file must be set
Yes, you can use any .htaccess file in any Apache instance regardless of platform. A service on a server is still a service on a server irrespective whether it is accessed on a local network (or even the same machine) or via a wider network (i.e. the Internet).
Set AllowOverride All
in configration file your Problem will b resolved.
.htaccess files are not considered when running php from the command line because Apache isn't called. But, as long as you are making a web request through Apache, and you have AllowOverrides configured properly for that directory, the .htaccess should be read and used by Apache.
Regardless of the setting in your config file, if you do not want online access do not forward port 80 to your server, if you do want online access then do forward port 80.
Not much detail in your question, but let me try an angle that hasn't been taken yet (as far as I noticed).
If you're asking why the .htaccess file works for this request:
http://myserver.com/mypage
Or even this request:
http://localhost/mypage
But not this request:
file://www/mypage
It's because the first two are actual HTTP requests, requiring the page to be 'served' by Apache. Apache (assuming a correct configuration for your situation) processes the .htaccess file while serving the request.
That whole process is bypassed for the third 'request', because that's not a HTTP request, that's a local filesystem request. In that case the web browser is loading a file much like a word processor. No web server is ever contacted, so the .htaccess file is meaningless.
If that's what you mean by local, then to my knowledge there's no way to get a browser to process the .htaccess file for a local request.
But in the future, there's a world of difference between requesting a flie for a local server, and loading a file from a local system.
Again, this is only my take on one way your question could be interpreted, if indeed you're referring to requesting the file from a local web serve - check the configuration as many hove suggested. (And check that you're running Apache too.)
If it means running on Windows .htaccess, use XAMPP and change the hosts file to have the same domain as the web server. Then test is locally.