With some help (also asked on SO, as this wasn’t a strict WP question), and some testing, the following ended up working for me (added a slash just before the $
sign):
RewriteRule ^galleries/(.*)/$ /portfolio/$1 [R=301,NC,L]
As the galleries are actual directories, not files, they have a slash at the end:
http://subdomain.example.com/galleries/headshots/
Here ---^
Related Posts:
- Place static HTML files in path below WordPress page
- htaccess, site and staging in subdirectories
- 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?
- File and directory permissions
- htaccess rewrite for author query string when WP is in subfolder
- .htaccess for wordpress inside another wordpress install
- Isolating WordPress to a subfolder
- Remove year and month in URL using .htaccess
- Permalinks not working on second wordpress installed in a subdirect
- Move wordpress to folder without changing urls
- Rewrite rule not working
- Change wp-content without changing the name of the folder
- How to restrict access to wp-content, wp-includes and all sub-folders
- .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
- Redirect main domain to subdirectory
- Exclude subfolder from WP-redirect works with html but not php files
- Can’t Access Subdirectory
- How can i redirect one url to another url using .htaccess or add_rewrite_rule
- Override htacces rule only for specific directory
- Fixing custom 404 pages broken by WordPress in a subdirectory
- WP install in sub-dir white screen
- Drawbacks to using Options -Indexes
- WordPress installed in root, need second in subdirectory with different domain
- 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
- External content won’t load in iframe in Safari
- 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
- Disable directory browsing of uploads folder
- Creating a copy of a website in a subdirectory, wp-admin redirect problem
- disable WordPress 404 for one specific page/folder to receive actual php errors
- .htaccess Non-‘www’ to ‘www’ Subdomain Redirection Only Works for Homepage
- Access sub-domain when root public_html is protected with .htaccess password
- Cannot access subdirectory subpages
- How to execute WordPress as though it is in the root folder while it is installed in a subdirectory?
- How can I create a smarter .htaccess file that will add a directory?
- WP Codex answer incomplete? Put WP in subdirectory. .htaccess change required
- 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
- Install second wordpress in root subfolder, Error 404
- Remove subdirectory from links
- How to properly give WordPress its own directory
- htaccess- to hide subdirectory slug only from the post
- How to direct users to a subcatalog
- Installing wordpress on subdirectory 2 levels down
- Cannot Override WordPress 404 for a Sub-Directory
- I can access subdirectory, but not files within it
- .htaccess and virtual host configuration for WP in its own directory
- Giving WordPress it’s own directory and using .htaccess Directory Index
- Add-on domain works in WordPress but links still lead to subdomain
- htaccess – Redirect to subfolder without changing browser URL
- Permalink Issues by Installing WordPress in Subdirectory / Subfolder
- Admin-Ajax.php, SSL, Non-SSL
- WordPress site displaying 404 for any page apart from index
- Cant block wordpress readme files
- WordPress keeps deleting .htaccess file
- Prevent users from browsing through the media galleries
- How to modify the .htaccess to force ssl on login and admin pages
- Server crashed trying to restore wordpress multisite, images are not found pls help
- Create subdomain masking for each user in WordPress
- Redirect from different port to subdomain – htaccess
- WordPress Redirect 301 register page
- Remove base slug in permalinks of hierarchical custom post type
- Only expose routes with prefix /wp-json on WordPress using Apache
- WordPress rewrite rules don’t need ^?
- Hardening wordpress: blocking /includes with htaccess
- Install a Network under a mapped domain
- Modify the .htaccess file
- sitemap contains weird links and does not contain my pages [closed]
- Wrong Redirect/Rewrite Rules?
- want to rewrite an URL in wordpress
- Redirections and rewrites to subdomain
- Unable to access folders in same level as wordpress installation
- Multisite Subdirectory with same domain subdomain
- Conflict with Force SSL and Rewrite Rules
- Loading index.php contents which located outside blog folder for post single page
- How to rewrite 404 to home page using htaccess?
- “Oops.” error on an html file directly uploaded to a subdirectory of my WordPress site
- How do I reset a rewrite?
- VServer/Rootserver/Shared Hosting: Multiple WordPress installations each having their unique domain?
- How do I make WordPress revise an .htaccess file a certain way?
- Sub domain URL slash / missing after domain and before Post & page slug
- I need to make one folder private
- Force HTTPS for mapped domain pointing to wordpress domain
- How can I restrict access, by IP, to the `wp-admin` folder/Dashboard?
- adding a rewrite rule in wordpress functions file
- Missing visual editor after placing a redirect rule into the .htaccess file
- Why my wp site always redirecting to the old website path..?
- Hiding wp-config.php via .htaccess on an install installed in another directory?
- WordPress redirection
- Home page returns 404