Directory URL Rewrite
A lightweight WordPress plugin that creates SEO-friendly URLs using WordPress Rewrite API. This plugin allows dynamic URLs such as: https://example.com/details/John/Smith/ and automatically maps them to a WordPress page while passing the values as query variables.Smart Query String
by Gulshan Chauhan · github.com/gulshanbasouli/directory-url-rewrite-for-wordpress
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/gulshanbasouli/directory-url-rewrite-for-wordpress/archive/refs/heads/master.zipA lightweight WordPress plugin that creates SEO-friendly URLs using WordPress Rewrite API.
This plugin allows dynamic URLs such as:
https://example.com/details/John/Smith/
and automatically maps them to a WordPress page while passing the values as query variables.
Features
- SEO-friendly URLs
- WordPress Rewrite API integration
- Custom query variables support
- Plugin activation/deactivation hooks
- Lightweight and fast
- No database tables required
Example
Incoming URL:
https://example.com/details/John/Smith/
Internally rewritten to:
https://example.com/index.php?page_id=177&firstName=John&lastName=Smith
You can then access these values inside your template:
$firstName = get_query_var('firstName');
$lastName = get_query_var('lastName');
Installation
Method 1 - Upload Plugin
- Download the plugin files.
- Upload the plugin folder to:
/wp-content/plugins/
- Login to WordPress Admin.
- Navigate to:
Plugins → Installed Plugins
- Activate the plugin.
Permalink Configuration
After activation:
- Go to:
Settings → Permalinks
- Click:
Save Changes
This will refresh WordPress rewrite rules.
How It Works
The plugin registers:
Rewrite Tags
%firstName%
%lastName%
Rewrite Rule
details/{firstName}/{lastName}/
Example:
/details/John/Smith/
The values are automatically passed to WordPress and can be used within your page template.
Using Query Variables
Inside your page template:
$firstName = get_query_var('firstName');
$lastName = get_query_var('lastName');
echo $firstName;
echo $lastName;
Output:
John
Smith
Customization
Change Target Page
Current rewrite target:
index.php?page_id=177
You can replace it with another page:
index.php?page_id=250
or use a page slug:
index.php?pagename=directory-profile
Change URL Structure
Current structure:
/details/John/Smith/
You can modify it to:
/profile/John/Smith/
by updating the rewrite rule.
Use Cases
- Business Directories
- Member Profiles
- Staff Directories
- Doctor Listings
- Real Estate Agents
- Service Providers
- Custom Search Result Pages
- Dynamic Landing Pages
Requirements
- WordPress 5.0+
- PHP 7.4+
- Pretty Permalinks Enabled
Changelog
Version 1.0.0
- Initial release
- Added custom rewrite tags
- Added SEO-friendly URL support
- Added activation/deactivation rewrite flushing
Author
Gulshan Chauhan
Portfolio: https://portfolio.perfectprofessionist.com/
GitHub: https://github.com/gulshanbasouli
License
GPL v2 or later