The part between the # BEGIN WordPress
and # END WordPress
will always be rewritten when the permalinks are flushed. You can either place your extra rewrite rules before this segment, or you can add register them in WordPress as external rewrite rules. If you flush your rules now (by visiting the Permalinks page, for example), your extra rules will be added to the .htaccess
file.
add_action( 'init', 'wpse12708_init' );
function wpse12708_init()
{
global $wp_rewrite;
$wp_rewrite->add_external_rule( 'mobile/([^/]+)$', 'mobile/index.php?action=$1' );
$wp_rewrite->add_external_rule( 'certificates/30-Days-Certificate-([0-9]+)$', 'pdf/index.php?type=30day&period=$1' );
$wp_rewrite->add_external_rule( 'certificates/12-Month-Certificate$', 'pdf/index.php?type=12Month' );
}
Related Posts:
- Masking wp-content/themes/name/images to just images directory using htaccess
- Passing parameters to a custom page template using clean urls
- Use subdomain for certain urls
- Clash of the rewrites
- 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?
- WordPress keeps writing rewrite rules to .htaccess
- WordPress Rewrite
- Dynamic URL, not a physical page within the database
- unexpected problem in url rewrite
- 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
- Issue with using .htaccess to redirect feedburner feed
- Remove all categories from URL
- Custom rewrite rule
- Remove special characters in a URL
- Add query string to url and display it as normal url part /folder/
- Alias ‘wp-content’ directory to something shorter (framework?)
- WordPress .htaccess – route other URLs to another app
- Map alt domain to specific section of website w/o MU
- Rewrite rule to load images from production does nothing
- 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
- Disable Pagination on Pages
- Rewrite Preview URL to include index.php
- subdirectory install breaking existing links
- a one-off rewrite rule
- .htaccess rewrite
- How can I dynamically generate an image with a static image URL?
- Change htaccess to redirect to index.php in subfolder
- How to remove wordpress directory slash
- Cannot access wp-admin without trailing slash – .htaccess configuration for WordPress behind a nginx proxy
- Changed pagination URLS to use p= instead of paged=
- Wildcard forward all posts and pages with few exceptions
- “View post” leads to odd URL
- React Router with WordPress
- joomla to wordpress migration and 404 errors issues [closed]
- Rewriting “pretty” blog category URL with htaccess / add_rewrite_rule() causes 404 page
- Replace specific middle part of url
- Map secondary domain to other’s virtual subfolder
- 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
- htaccess rewrite, adding segment to url
- Rewrite vs Redirect from ?p={ID}
- Is WordPress API visible from PHP file called in htaccess
- Having WordPress control only certain pages with .htaccess?
- ow to change cutsom page url of wordpress site using htaccess
- Help with a custom rewrite
- Rewrite specific action url
- force www rewrite if wordpress put in a folder
- 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
- Rewrite rule that wp-login.php?action=register is left alone
- 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
- WordPress URL redirect and replace ? question mark
- Help with .htaccess setup to hide WordPress Directory
- Pretty URL via Rewrite
- Fresh install redirects to www, breaking page loads
- Rewrite Url using .htaccess or hook
- Is it possible to rewrite a page URL from ID to name from an API?
- 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
- Url wordpress rewrite
- ModRewrite not working properly
- .htaccess RewriteRule to include post type and taxonomy
- URL rewrite results in a 404, but everything should work!
- Migration from old CMS to WordPress 301 redirection rules?
- Simple URL rewriting gone wrong
- Stop wordpress to redirecting home page if no page found
- Additional .htaccess rules based on wp page
- What is the proper way to use add_rewrite_rule to remove the (question mark)?
- WordPress total posts per page changed and now 404 Http error comes out [closed]
- Can’t get pretty permalinks to work without index.php
- How to redirect a virtual page (e.g. /blog) to the home page?
- How to rename the WordPress wp-login.php running on IIS6?
- Rewrite Page Parameters
- WP-Include rewrite directory