Apache – 嗨软 https://ihacksoft.com/archive 分享最好用的常用软件 Tue, 22 Nov 2022 02:41:09 +0000 zh-CN hourly 1 https://wordpress.org/?v=4.9.26 Apache的Rewrite原来就是这样!管它是PHPnow还是XAMPP https://ihacksoft.com/archive/1275.html https://ihacksoft.com/archive/1275.html#comments Fri, 21 Jan 2011 02:49:17 +0000 https://ihacksoft.com/?p=2004   公司有一台服务器上装的是XAMPP,没有开启Rewrite重定向功能,前天有云和的农产品网上交易市场网站要放上来,开发商那边发来了网站文件和数据库.sql文件,并标明哪个是数据库配置文件。这样我就顺利把网站搭建在了服务器上,但是我发现它有很多伪静态链接,服务器必须得支持URL Rewrite才行。我就去翻关于XAMPP开启rewrite的文章,结果找到的基本是这样的方法:

  在你的XAMPP安装目录下找到httpd.conf 这个文件( 位于\xampp\apache\conf\httpd.conf),用记事本或文本编辑器打开它
“Ctrl+F”找到“AllowOverride None”,替换为”AllowOverride All“。(总共有两个,应该是修改第一个就可以了,不过你把两个都改了也没影响),再找到”#LoadModule rewrite_module modules/mod_rewrite.so“,把前面的”#”号去掉,重启XAMPP。

  前几天还写了过PHPnow实现Discuz!伪静态URL Rewrite,其实后来通过我的测试,我已经全部搞懂了。跟PHPnow和XAMPP根本没有关系,它们只是集成包啊!关键就在Apache呀!

  上面搜索到的方法,我试了没有用。后来我知道它是针对Apache独立服务器的,而我服务器上的Apache是分虚拟主机的。Apache虚拟主机如何添加?赶快看这里:Apache添加虚拟主机。以下我以我的实例来清楚地写一下Apache虚拟主机开启Rewrite的方法:

  1、打开apache\conf\httpd.conf,添加:

<Directory "E:/Program Files/yunhe">
    Order allow,deny
    Allow from all
</Directory>

  2、打开apache\conf\extra\httpd-vhosts.conf,Apache添加虚拟主机里不是提到了添加这样一个模块嘛:

<VirtualHost *:80>
    ProxyPreserveHost On
    DocumentRoot "E:/Program Files/tuan"
    ServerName  tuan.jxbot.com
    DirectoryIndex index.php
    <Directory "E:/Program Files/tuan"> 
     Options Indexes FollowSymLinks 
     AllowOverride None 
     Order allow,deny 
     Allow from all 
 </Directory>
</VirtualHost>

原来只要把上面的AllowOverride None改成AllowOverride All就行了!!!看我的配置:

<VirtualHost *:80>
    ProxyPreserveHost On
    DocumentRoot "E:/Program Files/yunhe"
    ServerName  yunhe.jxbot.com
    DirectoryIndex index.php
    <Directory "E:/Program Files/yunhe"> 
      Options Indexes FollowSymLinks 
      AllowOverride All 
      Order allow,deny 
      Allow from all 
  </Directory>
</VirtualHost>

  3、重启Apache。不需要像上面所说的重启XAMPP,我说了Rewrite只是和Apache相关,是Apache的一个功能。看,成功了!

title
]]>
https://ihacksoft.com/archive/1275.html/feed 2
Apache“the requested operation has failed”解决方法 https://ihacksoft.com/archive/1272.html https://ihacksoft.com/archive/1272.html#respond Tue, 18 Jan 2011 09:00:55 +0000 https://ihacksoft.com/?p=2001 the requested operation has failed。搜索了一下,找到解决方法:开始,运行,CMD,退到httpd.exe的目录,然后:httpd.exe -w -n "Apache" -k start。发现不对,因为我是apache2.2,改成:httpd.exe -w -n "Apache2.2" -k start,成功了!提示了httpd-vhosts.conf里第几行配置出错了,马上打开httpd-vhosts.conf进行修改,再次重启Apache,成功! ]]>   今天早上在服务器上重启Apache发现启动不了,提示:the requested operation has failed。搜索了一下,找到解决方法:开始,运行,CMD,退到httpd.exe的目录,然后:httpd.exe -w -n "Apache" -k start。发现不对,因为我是apache2.2,改成:httpd.exe -w -n "Apache2.2" -k start,成功了!提示了httpd-vhosts.conf里第几行配置出错了,马上打开httpd-vhosts.conf进行修改,再次重启Apache,成功!

]]>
https://ihacksoft.com/archive/1272.html/feed 0
Apache添加虚拟主机 https://ihacksoft.com/archive/1237.html https://ihacksoft.com/archive/1237.html#respond Sat, 25 Sep 2010 07:34:07 +0000 https://ihacksoft.com/?p=1966 Apache添加虚拟主机,在XAMPP下测试成功!

一、打开xampp\apache\conf下的httpd.conf,添加网站目录的访问权限:

<Directory "E:/Program Files/tuan">
    Order allow,deny
    Allow from all
</Directory>

]]>
Apache添加虚拟主机,在XAMPP下测试成功!

一、打开xampp\apache\conf下的httpd.conf,添加网站目录的访问权限:

<Directory "E:/Program Files/tuan">
    Order allow,deny
    Allow from all
</Directory>

二、打开apache\conf\extra\httpd-vhosts.conf,添加:

<VirtualHost *:80>
    ProxyPreserveHost On
    DocumentRoot "E:/Program Files/tuan"
    ServerName  tuan.jxbot.com
    DirectoryIndex index.php
    <Directory "E:/Program Files/tuan">
     Options Indexes FollowSymLinks
     AllowOverride None
     Order allow,deny
     Allow from all
 </Directory>
</VirtualHost>

三、重启Apache。

]]>
https://ihacksoft.com/archive/1237.html/feed 0
Apache开启Rewrite的方法 https://ihacksoft.com/archive/1192.html https://ihacksoft.com/archive/1192.html#comments Wed, 24 Mar 2010 07:57:22 +0000 https://ihacksoft.com/?p=1921 加载Rewrite模块

在conf目录下httpd.conf中找到
LoadModule rewrite_module modules/mod_rewrite.so
这句,去掉前边的注释符号“#”,或添加这句。 ]]>
加载Rewrite模块

在conf目录下httpd.conf中找到
LoadModule rewrite_module modules/mod_rewrite.so
这句,去掉前边的注释符号“#”,或添加这句。

允许在任何目录中使用“.htaccess”文件,将“AllowOverride”改成“All”(默认为“None”)

# 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

注:在Windows系统下不能直接建立“.htaccess”文件,可以在命令行下使用“echo a> .htaccess”建立,然后使用记事本编辑。

]]>
https://ihacksoft.com/archive/1192.html/feed 1