Apache Multiple Rewrite Rules

前端 未结 1 658
孤街浪徒
孤街浪徒 2020-12-19 16:20

I have a 2 sets of rewrite rules. This is the Virtual Host:


    ServerName datingjapan.co
    ServerAlias *.datingjapan.co
    Rewri         


        
相关标签:
1条回答
  • 2020-12-19 16:31

    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>
    
    0 讨论(0)
提交回复
热议问题