I am trying to add custom rules using the wordpress add_rewrite_rule function, but they do not work. It is strange that rules are added and matched against my URL whenever I check them using the Monkeyman Rewrite Analyzer plugin.
When I try to access a page, it redirects to the wrong location.
Here is my code:
add_rewrite_tag('%cc%','([a-zA-Z]+)'); add_rewrite_tag('%id%','([0-9]+)'); add_rewrite_rule('job-details/([0-9]+)$', 'index.php?pagename=jobs&cc=show&id=$matches[1]', 'top'); global $wp_rewrite; $wp_rewrite->flush_rules();
As for my URLs, if I try to access the site.com/job-details/1 URL, it redirects me to / jobs /, which is the page associated with my plugin.
Here is my .htaccess file
RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # uploaded files RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule . index.php [L]
Samer bechara
source share