微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在apache localhost服务器上使用.htaccess文件

好吧,我得到了一个Apache本地主机服务器,并运行PHPMysqL。 现在我想能够使用一个.htaccess文件,以及使用RewriteRule ,但我不知道该把它放在哪里。

我有这些目录:

C:devprogs其中Apache PHPMysqL存储在每个子目录中,即。 C:devprogsApache等等…

C:devwww这里存储了所有的站点文件

使用.htaccess文件阻止错误的请求

Angular html5模式不能在Apache中工作

.htaccess指令*不*redirect某些URL

IP范围.htaccess文件mod_rewite

.htaccessredirect仅适用于部分url

我需要知道在哪里把.htaccess文件,我需要做什么configuration,如果我是我的希望和梦想都是没有的。

谢谢

.htaccess重写和条件

为什么redirect不断改变地址栏

.htaccess RewriteRule添加到URL的驱动器path

在Apache Htaccess中正确使用KeepAlive

Mod_rewrite将example.com/page.PHP?v1=abc&v2=def改为example.com/abc/def

.htaccess是一个配置文件,应该存储在你的页面。 总之,它应该在你的情况下在c:devwww中,但你也应该读一下 。 BTW不要忘记打开mod_rewrite从它所在的行删除一个哈希

Loadmodulee rewrite_module modules/mod_rewrite.so

并通过更改来启用.htaccess

AllowOverride None

AllowOverride All

在localhost的Apache服务器上启用.htaccess

1) Find your apache directly which uses the PHP installation . 2) Open your httpd.conf with notepad,Which is located in the path apacheconf directory 3) Find the code like below #Loadmodulee 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

您将.htaccess文件放置在您要代码控制的Web目录(以及任何子目录)中。 对于重写,它通常在根目录中,并作用于index.PHP页面

例如,如果将.htaccess文件放在 dev www 目录下,并且.htaccess文件具有像RewriteRule ^(.*)$ /index.PHP?/$1 [L]这样的正则表达式获取URL中的所有字符并将它们追加到/index.PHP? 脚本。 /$1是正则表达式的反向引用。

尝试这个。

<Ifmodulee mod_rewrite.c> RewriteEngine On RewriteBase /projectfolder/ RewriteRule ^index.PHP$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /projectfolder/index.PHP [L] </Ifmodulee>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐