The question is about doing this with .htaccess
, but why not disabling author pages from within WordPress instead?
This would achieve the same result while making the subdirectory concern irrelevant altogether (and also works regardless of permalink structure settings)
Sample code that sets all urls to author pages to a 404 error:
add_action( 'template_redirect',
function() {
if ( isset( $_GET['author'] ) || is_author() ) {
global $wp_query;
$wp_query->set_404();
status_header( 404 );
nocache_headers();
}
}, 1 );
add_filter( 'author_link', function() { return '#'; }, 99 );
add_filter( 'the_author_posts_link', '__return_empty_string', 99 );
(code taken from this plugin: Disable Author Archives)
Related Posts:
- Place static HTML files in path below WordPress page
- Remove year and month in URL using .htaccess
- Rewrite rule not working
- .htaccess redirects disappeared after re-saving permalinks
- Protect Upload Folder Files With Ampersand Problem
- Remove File Extension for Page Outside of WordPress
- WordPress URL/Folder ReWrite using Htaccess
- WordPress mod_rewrite is canceling/overwriting my other mod_rewrite rule
- How can i redirect one url to another url using .htaccess or add_rewrite_rule
- Override htacces rule only for specific directory
- mod_rewrite loop, redirecting http to https on certain section of wordpress blog
- blocking access to all post/tag URIs via htaccess
- Site in subfolder – all pages work except home
- htaccess, site and staging in subdirectories
- How to write .htaccess so that https is on for subpages only but not the home page
- How to create a redirect in the .htaccess file, with 2 exceptions
- 404 error Additionally 403 Forbidden error on a URL
- Custom rewrite rule, url returning 404
- mod_rewrite doesn’t work as I want even with JSON API Plugin disabled
- I have a page using a pretty url and a mod_rewrite rule matching it. I expected it to give an error but it’s working. Why?
- disable WordPress 404 for one specific page/folder to receive actual php errors
- .htaccess Non-‘www’ to ‘www’ Subdomain Redirection Only Works for Homepage
- How can I create a smarter .htaccess file that will add a directory?
- Rewriting subfolders to specific parent folder in WordPress
- Redirect WordPress site to a landing (construction) page using htaccess, with access to /wp-admin and /invoice
- htaccess redirect to path
- I can access subdirectory, but not files within it
- htaccess mod_rewrite not working
- Add-on domain works in WordPress but links still lead to subdomain
- .htaccess – how to force “www.” in a generic way?
- How does RewriteBase work in .htaccess
- Improve wordpress security by hiding non public resources
- htaccess rewrite conflict with wordpress rules and ssl
- Plugin to edit htaccess file
- Serve apache 404 for missing assets rather then wp 404 template WP_Rewrites
- Permalinks not working on second wordpress installed in a subdirect
- Change wp-content without changing the name of the folder
- Using “wordpress_logged_in” to restrict direct access to uploads folder in 2021
- How to restrict access to wp-content, wp-includes and all sub-folders
- Is it possible to dynamically redirect URL using htaccess?
- Which WordPress scripts need to be executable for a fresh installation?
- How to rewrite WordPress uploads folder to another folder using htaccess
- Keep getting 401 error from WordPress on AWS Lightsail
- Setup Permanent 301 Redirects after moving to Https [closed]
- Force www to non-www on a subdomain in WordPress?
- WP site URL changed to have HTTPS but still homepage does not redirect
- Why does multisite bypass WordPress for wp-content, wp-admin, wp-includes and .php files?
- need a help for modify .htaccess rule [closed]
- .htaccess ‘down for maitenance’ and WordPress
- Which is better: 301 Redirect in my .htaccess file or a plugin like Redirection?
- Fixing custom 404 pages broken by WordPress in a subdirectory
- I can’t access the admin panel links as I click it shows 403 error
- 403 error on admin login page
- How to hide login form if basic authentication fails?
- Redirect an old link to new site homepage [closed]
- a one-off rewrite rule
- .htaccess rules for blocking bots with an extra condition
- WordPress – Promoting A Dev Build In A Subdirectory To Production / Root Directory
- .htaccess RewriteRule always overwritten – how to prevent?
- Redirect old domain with query paramaters
- What might be removing my redirects from my htaccess?
- Mod_Rewrite to show only last subcategory in URL
- My Homepage Suddenly Disappeared and I Can’t Get It Back
- WordPress .htaccess to consider blog as directory
- Redirect – remove custom query string
- mod-rewrite exception? keep #hash in matching urls?
- Password protect directory but not files
- fix 302 redirection error on https
- main-domain of wordpress keep redirecting to subdomain
- How to deny access to a particular wordpress site url
- Rewrite URL in address bar for a specific page [closed]
- Home links redirects to old site
- What’s the best way to manage a lot of 301 redirects in WordPress?
- mod-rewrite rules grabs “broken permalinks”, too
- Configure .htaccess to have a WordPress single site installation with all subdomains pointing to the same pages?
- Azure WordPress deny access to xmlrpc
- Understanding Redirects
- domain redirection is not working from old to new
- Deny,Allow on .htaccess isn’t working
- Using htaccess to prevent spam through wp-comments-post.php
- Install second wordpress in root subfolder, Error 404
- Pretty URL via Rewrite
- URL Rewrite 404
- Remove subdirectory from links
- modifying htaccess for localhost with a custom port
- .htaccess redirects for posts in new directory and new domain
- domain.in/wp-admin give the result to 403 Access to this resource on the server is denied!
- htaccess and redirect to new url using regex
- ModRewrite not working properly
- Restrict Content for only Contributors via .htaccess
- Redirect from domain.com to subdomain.domain.com
- customize urls displayed by previous_post_link and next_post_link
- MAMP.app & .htaccess – Can’t override after config
- register_post_type and register taxonomy and htaccess
- Why ‘Authorization Required’ is coming on wordpress login
- Restricting direct downloads of wp content files, but allow them on the website.
- Forward blog requests to another URL
- .htaccess rewrite rule stopped working for wordpress site after moving server
- How To Add CSP frame ancestors in WordPress Website? [closed]
- How do I modify each instance of setcookie?