开发者

Is there any other way to run .htaccess file on the local server?

Is there any way to ru开发者_如何学Gon the .htaccess file on the local server without being online?


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 have suggested. (And check that you're running Apache too.)


.htaccess file is never being "run". It is merely a configuration file. An unnecessary one, as each of its commands can be used in the main httpd.conf configuration file.

What is the background that led you to this question?

To enable this file, the AllowOverride All setting in the httpd.conf file must be set.


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 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.


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).


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.


Set AllowOverride All in the configration file and your problem will be resolved.


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 it locally.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜