.htaccess & WordPress: Exclude folder from RewriteRule

前端 未结 17 1567
不思量自难忘°
不思量自难忘° 2020-11-29 06:37

I have this .htaccess file in WordPress. It\'s located at /public_html/ (web root). I need to exclude a folder (csNewsAd) from the rewrite engine. I\'ve tried this, based fr

17条回答
  •  孤街浪徒
    2020-11-29 07:21

    I know its an old post, but it still helped me. I had the additional problem of several blocks of RewriteRules:

    ##
    ## White listed folders
    ##
    RewriteCond %{REQUEST_URI} !^/(phplist|phplist/.*)$
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_FILENAME} !/.well-known/*
    RewriteCond %{REQUEST_FILENAME} !/storage/app/uploads/.*
    RewriteCond %{REQUEST_FILENAME} !/storage/app/media/.*
    ...
    RewriteCond %{REQUEST_FILENAME} !/modules/.*/(assets|resources)/.*
    RewriteRule !^index.php index.php [L,NC]
    
    ##
    ## Block all PHP files, except index
    ##
    RewriteCond %{REQUEST_URI} !^/(phplist|phplist/.*)$
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_FILENAME} \.php$
    RewriteRule !^index.php index.php [L,NC]
    
    ##
    ## Standard routes
    ##
    RewriteCond %{REQUEST_URI} !^/(phplist|phplist/.*)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    

    and had to add my RewriteCond before every block...

提交回复
热议问题