Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8991139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:39:27+00:00 2026-06-15T22:39:27+00:00

In my root .htaccess file I have the following WordPress code: RewriteRule ^index\.php$ –

  • 0

In my root .htaccess file I have the following WordPress code:

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]

Slightly different to the standard code because the WordPress files are in a “wordpress” directory but rewrites still appear relative to the domain root. For example a blog post can be called site.com/this-is-a-blog-post.php and the rewrite works.

This works great except when I want to use htpasswd to protect a directory on the site. If I add the following code to a .htaccess file in any directory I get a 404 when trying to browse to that directory:

AuthName "Private"
AuthUserFile "/home/passwd"
AuthType Basic
require valid-user

This code works correctly when the last line of the WordPress rewrite code is commented out, but with the WordPress code intact my password protected directory gives a 404.

So I have a conflict between the two .htaccess files somehow. I have tried writing a bunch of RewriteCond’s to try and exclude the subdirectory with the password applied but can’t nail it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:39:29+00:00Added an answer on June 15, 2026 at 10:39 pm

    Ok, Murphy’s Law, just worked it out after posting the question!

    The extra condition needed for the WordPress rewrite is:

    RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|#.*|\?.*|/[^.]*)$  [NC]
    

    So the complete WordPress rewrite code becomes:

    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|#.*|\?.*|/[^.]*)$  [NC]
    RewriteRule . /wordpress/index.php [L]
    

    Now I’ll go finish my humble pie.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following .htaccess RewriteEngine On RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?type=Navigation&action=$1 RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?type=Navigation&action=$1 Options
I have created following rule in the .htaccess file located at the root of
I have the following rule defined in the .htaccess file of my webapplication's root
I have this .htaccess file in WordPress. It's located at /public_html/ (web root). I
I have the following .htaccess file in the root of my application: RewriteEngine On
Let's say we have the following schema: root/ application/ -public/ index.php css/ img/ javascript/
I have the following .htaccess file in my root: Options +FollowSymlinks RewriteEngine on RewriteBase
I have the following rewrite rule in my .htaccess file on the root of
I have placed .htaccess file in my server's root folder with following content: Redirect
I have an htaccess file as follows: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} -f

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.