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

来源:互联网 发布:键盘钢琴软件电脑 编辑:程序博客网 时间:2024/06/09 16:26

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

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

    
         ServerAdmin heiyeluren@unixsky.net
         DocumentRoot /usr/www/heiyeluren
         ServerName heiyeluren.unixsky.net
         ErrorLog logs/cal-error_log
         CustomLog logs/cal-access_log common
    

没有看出问题来呀?

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

     
       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]

     

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

    
        
             AllowOverride All
             Options Indexes FollowSymlinks MultiViews
             Order allow,deny
             Allow from all
        

         ServerAdmin heiyeluren@unixsky.net
         DocumentRoot /usr/www/heiyeluren
         ServerName heiyeluren.unixsky.net
         ErrorLog logs/cal-error_log
         CustomLog logs/cal-access_log common
    

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

其实就是加上了:

        
             AllowOverride All
             Options Indexes FollowSymlinks MultiViews
             Order allow,deny
             Allow from all
        

针对某个目录的设置。




原创粉丝点击