且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Apache的多重写规则

更新时间:2022-12-10 09:02:10

将仍然需要为最后一个标志是标示每一个重写规则的结束。排序规则也是重要的。改变你的code到这一点:

L will still be needed as Last flag is for marking end of each rewrite rule. Ordering of rules is also important. Change your code to this:

<VirtualHost *:80>
    ServerName datingjapan.co
    ServerAlias *.datingjapan.co
    DocumentRoot /var/www/html/datingjapan.co

    RewriteEngine on

    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^(.*) http://www.%{HTTP_HOST}$1 [R=301,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule ^(.*)$ /index.php?/$1 [L,QSA]
</VirtualHost>