.htaccess & WordPress: Exclude folder from RewriteRule

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

    .htaccess affects all directories underneath, so if you put an .htaccess in csNewsAd with the rewrite directives you want, it will take precedence over the root file.

    0 讨论(0)
  • 2020-11-29 07:16

    I was having a similar problem for two sites of mine. The comments I read here didn't work for me, but I finally got this code to work:

    <IfModule mod_rewrite.c>
      RewriteEngine on
    
      # stuff to let through (ignore)
      RewriteCond %{REQUEST_URI} "/folder1/" 
      RewriteRule (.*) $1 [L]
    

    obtained from https://www.drupal.org/node/30334

    0 讨论(0)
  • 2020-11-29 07:17

    Was having the same issue and found the answer to my problem here: http://kb.siteground.com/article/How_to_exclude_a_folder_from_Wordpress_permalinks.html

    --From the site

    To exclude the subfolders from the WordPress rewrite rules, you need to edit the .htaccess file and change the bold line below:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # RewriteRule . /index.php [L] # Original line
    RewriteRule ./ /index.php [L] # New line
    </IfModule>
    # END WordPress
    
    0 讨论(0)
  • 2020-11-29 07:18

    Place the line below in the .htaccess file in the root.

    ErrorDocument 401 default
    

    Had the exact same problem and this worked for me. It is not the problem that the redirects don't work. The problem is that the 401 (Authorization Required) error is nog defined so the "popup" doesn't show.

    0 讨论(0)
  • 2020-11-29 07:18

    It's worth noting that it matters where in the flow of the .htaccess this line goes.

    See here : http://tanyanam.com/technology/wordpress-exclude-directory-from-url-rewrite-with-htaccess - the line needs to come before the WordPress ones, it won't work after them.

    Rob

    0 讨论(0)
  • 2020-11-29 07:21

    you could add something like this:

    RewriteCond %{REQUEST_URI} !^/csNewsAd 
    

    but this should not be needed, because if csNewsAd indeed is a directory (folder) it should not be rewritten in the first place because of

    RewriteCond %{REQUEST_FILENAME} !-d
    

    are you sure there isn't anything else sitting between you and that folder, rights or (indeed) another .htaccess?

    0 讨论(0)
提交回复
热议问题