Apache中设置虚拟主机的URL重写功能

服务器被重装,我负责的模块很多都调不通,特别是涉及到很多url重写功能的,赶紧看看为什么。

打开 /usr/local/apache/conf/httpd.conf 配置文件,找到我那个虚拟主机的配置:

     <VirtualHost *:80>
         ServerAdmin heiyeluren@unixsky.net
         DocumentRoot /usr/www/heiyeluren
         ServerName heiyeluren.unixsky.net
         ErrorLog logs/cal-error_log
         CustomLog logs/cal-access_log common
     </VirtualHost>

没有看出问题来呀?

难道是我的 .htaccess 文件不对?赶紧打开 /usr/www/heiyeluren/.htaccess 看看:

      <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteBase /
       RewriteCond %{REQUEST_FILENAME} -f [OR]
       RewriteCond %{REQUEST_FILENAME} -d
       RewriteRule ^.*$ - [S=42]
     
       RewriteRule ^share/$ /share.php [QSA,L]
       RewriteRule ^(rss|rss2|atom|opml)/tag/([^/]+)/?$ /rss.php?rssver=$1&rsstype=tag&tag=$2 [QSA,L]
       RewriteRule ^(rss|rss2|atom|opml)/city/([^/]+)/?$ /feed.php?rssver=$1&rsstype=city&city=$2 [QSA,L]
       RewriteRule ^(rss|rss2|atom|opml)/pub/event/?$ /feed.php?rssver=$1&rsstype=pub_event [QSA,L]
       RewriteRule ^(rss|rss2|atom|opml)/pub/task/?$ /feed.php?rssver=$1&rsstype=pub_task [QSA,L]

      <IfModule mod_rewrite.c>

也没看出异常来呀~~~~ 赶紧找资料。。。原来是 httpd.conf 配置文件少了东西,修改 /usr/local/apache/conf/httpd.conf 再上面虚拟主机的上面加上内容,结果如下:

     <VirtualHost *:80>
         <Directory "/usr/www/heiyeluren">
             AllowOverride All
             Options Indexes FollowSymlinks MultiViews
             Order allow,deny
             Allow from all
         </Directory>
         ServerAdmin heiyeluren@unixsky.net
         DocumentRoot /usr/www/heiyeluren
         ServerName heiyeluren.unixsky.net
         ErrorLog logs/cal-error_log
         CustomLog logs/cal-access_log common
     </VirtualHost>

嘿嘿,重启apache,再测试,能访问了。

其实就是加上了:

         <Directory "/usr/www/heiyeluren">
             AllowOverride All
             Options Indexes FollowSymlinks MultiViews
             Order allow,deny
             Allow from all
         </Directory>

针对某个目录的设置。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值