Reputation: 129
i have a wordpress website with a cpt called jobs. i have a jobs archive enabled and the slug is set to 'work-for-us' currently the url of each job post looks like this:
http://localhost:8080/projects/pfs/work-for-us/job-1/
each job will have an apply button and i would like that to be also added into the url above.
i started this by adding a query string 'apply', now my url looks like this:
http://localhost:8080/projects/pfs/work-for-us/job-1/?apply
the output from the 'apply' query string will show an application form if it exists in the url.
everything above works as it should. the only thing i want to do is to make the url prettier so it doesnt have the '?' and will give me the same output just entering:
http://localhost:8080/projects/pfs/work-for-us/job-1/apply/
how to do i edit the htaccess file to achieve this.
here is my attempt:
RewriteRule ^work-for-us/(.*)/?apply$ work-for-us/$1/apply/ [R,L]
my current htaccess file sits in the root of pfs which is the wordpress website:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /projects/pfs/
RewriteCond %{THE_REQUEST} /(work-for-us/[^?]*)\?(apply) [NC]
RewriteRule ^ %1/%2? [R=302,L,NE]
RewriteRule ^(work-for-us/.+?)/(apply)/?$ $1?$2 [L,QSA,NC]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /projects/pfs/index.php [L]
</IfModule>
Upvotes: 0
Views: 38
Reputation: 786091
You can use this code in your /projects/.htaccess
file:
RewriteEngine On
RewriteBase /projects/
RewriteCond %{THE_REQUEST} /(work-for-us/[^?]*)\?(apply) [NC]
RewriteRule ^ %1/%2? [R=302,L,NE]
RewriteRule ^(work-for-us/.+?)/(apply)/?$ $1?$2 [L,QSA,NC]
Upvotes: 1