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
- How to add custom rewrite rule to .htaccess?
- 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?
- Hijacking the URL for filtering
- Custom rewrite rules are sending everything to index.php
- custom htaccess rewrite rule for page
- WordPress keeps writing rewrite rules to .htaccess
- WordPress Rewrite
- Dynamic URL, not a physical page within the database
- unexpected problem in url rewrite
- Redirecting all old links from previous EE site to new WP site in one go?
- Prevent WordPress from automatically correcting URLs
- Two “.htaccess” Files Located in Different Directories?
- 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
- hard flush_rewrite_rules() not regenerating .htaccess
- Map alt domain to specific section of website w/o MU
- Rewrite rule to load images from production does nothing
- Cleanup URL for a custom page in wordpress
- WordPress rewrite rules don’t need ^?
- WordPress SSL (https) is not working with custom permalink
- Changing RSS feed URL structure
- How to redirect http://mydomain/blog/blahblah/ to http://mydomain/blahblah/ in wordpress htaccess?
- add_rewrite_rule fro html to another url not working
- Adding rewrite rules directly to .htaccess file
- 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?
- Preserve Domain Alias
- My WP_options db rewrite_rules Does Not Work
- Disable Pagination on Pages
- Rewrite Preview URL to include index.php
- WordPress Redirecting Non Category Pages /page/nnn to their Canonical URLs
- 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
- Customise particular RSS permalink
- htaccess rewrite, adding segment to url
- RSS feed rewrite matching wrong rule
- 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
- Redirect htaccess [closed]
- 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
- How do I make WordPress revise an .htaccess file a certain way?
- 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
- Rewrite htacess rule doesn’t work
- WordPress pagination broken for page 2,3 with custom permalink. Redirects to baseurl
- Translatepress taxonomy and custom post type root FIX
- WordPress URL redirect and replace ? question mark
- Help with .htaccess setup to hide WordPress Directory
- Multiple permalink with and without category for same post
- Custom Params in URL
- Pretty URL via Rewrite
- Fresh install redirects to www, breaking page loads