.htaccess & WordPress: Exclude folder from RewriteRule

前端 未结 17 1566
不思量自难忘°
不思量自难忘° 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:04

    I first started doing this with Rails. At the top of the rails .htaccess are the following two lines.

    # RewriteCond %{REQUEST_URI} ^/notrails.*
    # RewriteRule .* – [L]
    

    When I finally followed their example it worked.

    I wanted to exclude images, javascripts, stylesheets, css, images-global, js-global (etc) so I changed the above to.

    RewriteCond %{REQUEST_URI} ^(images|javascripts|stylesheets|css|images-globa|js-global|js).*
    RewriteRule .* – [L]
    

    And it worked the way I needed.

    We won’t talk about how it is that I have so many different javascript, stylesheet and images folders….

    But this does make my “error” file less painful. If someone adds an image file that doesn’t exist, my dispatch doesn’t have to process it.

提交回复
热议问题