apache的rewrite规则无法加载问题

 apache的rewrite规则无法加载问题。

 

<VirtualHost *:80>

    ServerAdmin k@5.com

    DocumentRoot /data/web/xxx

    ServerName  www.xxx.net

     ServerAlias xxx.net

    DirectoryIndex index.php index.shtml index.html

     <Directory "/data/web/xxx">

         Options FollowSymLinks Includes

         AllowOverride None

         Order allow,deny

         Allow from all

    </Directory>

RewriteEngine On

RewriteRule ^vod-(.*)$ index.php\?s=/Home-vod-$1

RewriteRule ^news-(.*)$ index.php\?s=/Home-news-$1

RewriteRule ^ajax-(.*)$ index.php\?s=/Home-ajax-$1

RewriteRule ^tag-(.*)$ index.php\?s=/Home-tag-$1

RewriteRule ^gb-(.*)$ index.php\?s=/Home-gb-$1

RewriteRule ^cm-(.*)$ index.php\?s=/Home-cm-$1

</VirtualHost>

改成
<VirtualHost *:80>
    ServerAdmin k@5.com
    DocumentRoot /data/web/xxx
    ServerName  www.xxx.net
     ServerAlias xxx.net
    DirectoryIndex index.php index.shtml index.html
     <Directory "/data/web/xxx">
         Options All
         AllowOverride All
         Order allow,deny
         Allow from all
    </Directory>
RewriteEngine On
RewriteRule ^vod-(.*)$ index.php\?s=/Home-vod-$1
RewriteRule ^news-(.*)$ index.php\?s=/Home-news-$1
RewriteRule ^ajax-(.*)$ index.php\?s=/Home-ajax-$1
RewriteRule ^tag-(.*)$ index.php\?s=/Home-tag-$1
RewriteRule ^gb-(.*)$ index.php\?s=/Home-gb-$1
RewriteRule ^cm-(.*)$ index.php\?s=/Home-cm-$1
</VirtualHost>
 
即可。
 
区别在于

     <Directory "/data/web/xxx">

         Options FollowSymLinks Includes

         AllowOverride None

         Order allow,deny

         Allow from all

    </Directory>

    <Directory "/data/web/xxx">
         Options All
         AllowOverride All
         Order allow,deny
         Allow from all
    </Directory>
这个为正确的。
 
参考 http://www.d5s.cn/archives/107

 


本文转自 liang3391 51CTO博客,原文链接:http://blog.51cto.com/liang3391/812280

上一篇:如何解决Web Services出现System.UnauthorizedAccessExcepti


下一篇:项目重构之数据源配置与优化:log4j 配置数据库连接池Druid,并实现日志存储到数据库