Try something like the following at the top of the root .htaccess
file, before the existing WordPress directives (before the # BEGIN WordPress
comment marker):
RewriteCond $2 !^(index\.php)?$
RewriteRule ^(subfolder)/(.+) /$1/index.php?path=$2 [L]
The RewriteCond
directive is to ensure that it doesn’t try to rewrite requests for index.php
itself (or the directory). A request for /subfolder/
only will be served by /subfolder/index.php
without the path
URL parameter (by mod_dir).
Otherwise, all other requests to that subfolder (whether they map to files, directories or nothing at all) are passed to /subfolder/index.php
in the query string.
Related Posts:
- Masking wp-content/themes/name/images to just images directory using htaccess
- Rewrite rule to load images from production does nothing
- WordPress rewrite rules don’t need ^?
- Adding rewrite rules directly to .htaccess file
- a one-off rewrite rule
- How to remove wordpress directory slash
- Rewriting “pretty” blog category URL with htaccess / add_rewrite_rule() causes 404 page
- Map secondary domain to other’s virtual subfolder
- force www rewrite if wordpress put in a folder
- How do I make WordPress revise an .htaccess file a certain way?
- Pretty URL via Rewrite
- ModRewrite not working properly
- Can’t get pretty permalinks to work without index.php
- How to redirect a virtual page (e.g. /blog) to the home page?
- Add rewrite endpoint and .htaccess
- Generic htaccess redirect www to non-www
- How to remove “admin.php?page=” from wp-admin using .htaccess?
- SEO Friendly URLs for my plugin categories
- How do I remove a word from a url in WordPress using .htaccess?
- Rewrite rules in .htaccess get overwritten?
- Removing rules from .htaccess
- WordPress keeps writing rewrite rules to .htaccess
- WordPress Rewrite
- Dynamic URL, not a physical page within the database
- Prevent WordPress from automatically correcting URLs
- Server (WordPress) redirects files that are not supposed to (using htaccess)
- WordPress redirection to get url friendly
- Rewrite WordPress Custom URL
- htaccess: Remove trailing slash from URL ending with .xml/ only
- External/non-WP rewrite rule without QSA
- Remove all categories from URL
- Custom rewrite rule
- Remove special characters in a URL
- Alias ‘wp-content’ directory to something shorter (framework?)
- Map alt domain to specific section of website w/o MU
- Using custom mod_rewrite without breaking wordpress permalinks
- WordPress SSL (https) is not working with custom permalink
- How to redirect http://mydomain/blog/blahblah/ to http://mydomain/blahblah/ in wordpress htaccess?
- Double domain name in category URL-s
- Access files at new location using old file paths
- NextGEN Gallery Lightbox – Social Share URL Redirect
- Url Rewriting a dynamic wordpress page
- WordPress .htaccess blocks mine?
- My WP_options db rewrite_rules Does Not Work
- Rewrite Preview URL to include index.php
- WP is ignoring .htaccess rewritten URL
- subdirectory install breaking existing links
- .htaccess rewrite
- How can I dynamically generate an image with a static image URL?
- Rewrite wp-login.php URLS to static pages?
- Cannot access wp-admin without trailing slash – .htaccess configuration for WordPress behind a nginx proxy
- Wildcard forward all posts and pages with few exceptions
- Rewrite URLs – Custom Post Type – Post Slug, Taxonamy Slug
- URL Rewriting for PHP script on an image URL
- Change pagination url format
- How to redirect specific URL to Subdomain
- Replace specific middle part of url
- How to rewrite wordpress urls with index.php in them
- Custom Rewrite rule to captured post (rewrite rule to rewrite rule)
- Rewriting a subdomain page on one WordPress installation to a parent domain on another
- Redirecting /px/?q=x to /px/x/
- URL redirect on updating the post date
- WordPress keeps writing rewrite rules to .htaccess
- Changing URL scheme, mod_rewrite not helping
- RSS feed rewrite matching wrong rule
- Rewrite vs Redirect from ?p={ID}
- mod-rewrite exception? keep #hash in matching urls?
- Is WordPress API visible from PHP file called in htaccess
- Having WordPress control only certain pages with .htaccess?
- Localize URL bases
- Help with a custom rewrite
- How can I create custom URL routes?
- Rewrite specific action url
- 301 Rewriting htaccess
- WordPress .htaccess ignore path and subsequent .htaccess files in subfolders
- Overwrite WordPress’s URL rewrite not working
- 404 redirect based on url
- How to customize sub-URLs in a wordpress website (.htaccess)
- Proper way to set up rewrite with Wp
- Rewriting a date hierarchy into a ‘yyyy-mm-dd’ slug
- Exclude subfolder in WordPress permalink
- WordPress is adding “category” word before my actual category name in url (and this is unsolicited)
- Point 404 pages to homepage
- WordPress pagination broken for page 2,3 with custom permalink. Redirects to baseurl
- Help with .htaccess setup to hide WordPress Directory
- URL Rewrite 404
- Rewrite URL to get rid of wp-content etc and change URL
- Rewrite URL for attachments
- Moved WordPress to Subdirectory, still hijacking requests to files outside of its directory
- How to add gallery slug to attachment url?
- Rewrite URL query string for all pages
- Redirect A URL Pattern In WordPress Using .htaccess
- Migration from old CMS to WordPress 301 redirection rules?
- Simple URL rewriting gone wrong
- Custom Rewrite for Profiles
- What is the proper way to use add_rewrite_rule to remove the (question mark)?
- Function to rewrite URl in WordPress
- help with rewrite_tag and rewrite_rule for custom page GET variables [duplicate]
- How to rename the WordPress wp-login.php running on IIS6?
- Please give me the rewrite rules for my ugly urls