apache的rewrite規則無法載入問題

科技小能手發表於2017-11-12

 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


相關文章