Or you could just add the relevant directive to the top of the .htaccess
file directly. For example:
RewriteRule ^([^/]+)\.html$ /product/$1 [R=302,L]
This matches /anyname.html
(as in your example), but not /foo/bar/anyname.html
.
Related Posts:
- Server (WordPress) redirects files that are not supposed to (using htaccess)
- Alias ‘wp-content’ directory to something shorter (framework?)
- Wildcard forward all posts and pages with few exceptions
- Is WordPress API visible from PHP file called in htaccess
- Clash of the rewrites
- Will references to ugly links automatically redirect to their pretty url permalink?
- Hijacking the URL for filtering
- WP Login forms action URLs displayed as pretty URLs in browser (ex with Restore Password)
- custom htaccess rewrite rule for page
- Redirecting all old links from previous EE site to new WP site in one go?
- Prevent WordPress from automatically correcting URLs
- Rewrite WordPress Custom URL
- Custom rewrite rule
- WordPress .htaccess – route other URLs to another app
- Is there a ‘rake routes’ for wordpress?
- Changing RSS feed URL structure
- Double domain name in category URL-s
- Preserve Domain Alias
- WordPress redirects non-existing url to existing ones – how to disable
- Rewrite Preview URL to include index.php
- How to disable URL rewriting for specific URLs?
- How do I display only the parent page in the url
- How to remove wordpress directory slash
- React Router with WordPress
- How to redirect large amount of URLs?
- Redirecting /px/?q=x to /px/x/
- URL redirect on updating the post date
- Rewrite vs Redirect from ?p={ID}
- Redirect htaccess [closed]
- 301 Rewriting htaccess
- 404 redirect based on url
- How to customize sub-URLs in a wordpress website (.htaccess)
- WordPress is adding “category” word before my actual category name in url (and this is unsolicited)
- Multiple permalink with and without category for same post
- Fresh install redirects to www, breaking page loads
- Rewrite URL to get rid of wp-content etc and change URL
- taxonomy term in URL slug won’t forward to the correct term for custom post like it does for default categories/normal posts
- How to create short urls for sharing and downloadable content?
- Redirect A URL Pattern In WordPress Using .htaccess
- Migration from old CMS to WordPress 301 redirection rules?
- Changes done to .htaccess are not getting reverted back
- Generic htaccess redirect www to non-www
- Override default url for author pages?
- Multiple endpoints to same page
- Custom permalinks with NextGEN Gallery
- How to prevent redirection to max 2147483647 for larger values of the page query variable?
- How to remove “admin.php?page=” from wp-admin using .htaccess?
- How do I add a add_rewrite_rule without it redirecting?
- Rewrite rules in .htaccess get overwritten?
- Dynamic URL, not a physical page within the database
- Passing & Reading URL Parameters with URL re-writing
- Change default URL of image attachment
- Taking a value from PHP_URL_PATH won’t work after WordPress 5.5 update
- Display content according to current URL
- Using WP rather than .htaccess to redirect pages/posts
- htaccess: Remove trailing slash from URL ending with .xml/ only
- External/non-WP rewrite rule without QSA
- Custom URL rewrite to specific page template
- Map alt domain to specific section of website w/o MU
- How to redirect http://mydomain/blog/blahblah/ to http://mydomain/blahblah/ in wordpress htaccess?
- Append a query string to the end of every URL
- Url Rewriting a dynamic wordpress page
- subdirectory install breaking existing links
- .htaccess rewrite
- Change htaccess to redirect to index.php in subfolder
- Right url for custom post type
- Preserve old website URL structure after migrating to WordPress
- Rewriting “pretty” blog category URL with htaccess / add_rewrite_rule() causes 404 page
- Redirect a Blogger Page URL to wordpress
- WordPress keeps writing rewrite rules to .htaccess
- Changing URL scheme, mod_rewrite not helping
- How do I Redirect a WordPress Page?
- Re-directing URLs with dates to URLs without dates
- Having WordPress control only certain pages with .htaccess?
- wordpress url correction
- Flushing rewrite rules
- Help with a custom rewrite
- Rewrite specific action url
- Overwrite WordPress’s URL rewrite not working
- Proper way to set up rewrite with Wp
- Get logged in username in wordpress url
- URL problem: www.sitename.com/blog and www.sitename.com/learn using same WP installation
- WordPress 3.1.2 Network Enabled non-www to www
- Exclude subfolder in WordPress permalink
- 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
- Rewrite URL for attachments
- How to add gallery slug to attachment url?
- Pagination appearing twice in URL after rewrite
- URL Rewrite for CPT single posts
- Simple URL rewriting gone wrong
- What is the proper way to use add_rewrite_rule to remove the (question mark)?
- WordPress post-type create url rewriting
- How can i maintain permalink structure and avoid a 404 error when loading external content?
- Can’t get pretty permalinks to work without index.php
- How to redirect a virtual page (e.g. /blog) to the home page?
- WordPress 3.0 Multisite – Child sites and backends appearing blank
- How to rename the WordPress wp-login.php running on IIS6?
- Post pages are redirecting to the 404 page in wordpress