first, you need to add your custom_gallery_id
to query vars if you haven’t already:
add_filter( 'query_vars', 'wpse26388_query_vars' );
function wpse26388_query_vars( $query_vars ){
$query_vars[] = 'custom_gallery_id';
return $query_vars;
}
for your rewrite rule, you need to load a WordPress object– a page, a category, etc., and all internal rewrites must point to index.php. if topic, place, and new delhi are all pages, it would look something like this:
function wpse26388_rewrites_init(){
add_rewrite_rule(
'topic/([^/]+)/([^/]+)/gallery/([0-9]+)/?$',
'index.php?pagename=topic/$matches[1]/$matches[2]&custom_gallery_id=$matches[3]',
'top' );
}
also try out this plugin for analyzing and testing your rewrite rules.
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 do I remove a word from a url in WordPress using .htaccess?
- Hijacking the URL for filtering
- Rewrite rules in .htaccess get overwritten?
- Custom rewrite rules are sending everything to index.php
- custom htaccess rewrite rule for page
- Dynamic URL, not a physical page within the database
- Redirecting all old links from previous EE site to new WP site in one go?
- Two “.htaccess” Files Located in Different Directories?
- WordPress redirection to get url friendly
- Rewrite WordPress Custom URL
- htaccess: Remove trailing slash from URL ending with .xml/ only
- 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
- 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
- add_rewrite_rule fro html to another url not working
- Adding rewrite rules directly to .htaccess file
- NextGEN Gallery Lightbox – Social Share URL Redirect
- 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
- .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]
- 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
- Customise particular RSS permalink
- htaccess rewrite, adding segment to url
- RSS feed rewrite matching wrong rule
- Rewrite vs Redirect from ?p={ID}
- 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
- 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)
- 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
- Rewrite Url using .htaccess or hook
- Is it possible to rewrite a page URL from ID to name from an API?
- Moved WordPress to Subdirectory, still hijacking requests to files outside of its directory
- Url wordpress rewrite
- Add ReWrite from Old Pages to WordPress (remove .php)
- ModRewrite not working properly
- Fully mask *all* traces of WordPress installation subdirectory?
- .htaccess RewriteRule to include post type and taxonomy
- Redirect A URL Pattern In WordPress Using .htaccess
- URL rewrite results in a 404, but everything should work!
- Rewrite Question
- Migration from old CMS to WordPress 301 redirection rules?
- Stop wordpress to redirecting home page if no page found
- Additional .htaccess rules based on wp page
- Changes done to .htaccess are not getting reverted back
- 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 rename the WordPress wp-login.php running on IIS6?
- how to rewrite folder name in url to another name
- Add rewrite endpoint and .htaccess
- Rewrite Page Parameters
- WP-Include rewrite directory