0

I'm trying to rewrite this url www.domain.com/gallery/?university=birmingham to an seo friendly one like this www.domain.com/uni/birmingham/gallery

the (?university=birmingham) represent the taxonomy and gallery is the post type. At the moment this url (www.domain.com/gallery/?university=birmingham) works fine, it displays the right posts, just haven't had any success in rewriting it to the one above

I have tried doing this (which should work):

RewriteEngine On
RewriteRule ^uni/([0-9A-Za-z_-]+)/(.+)$ /$2?university=$1 [QSA,NC,L,R=302]


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /students/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /students/index.php [L]


</IfModule>

can anyone please point me in the right direction or show me what am doing wrong?

  • Why aren't you using the WordPress rewrite API? – TheDeadMedic Aug 28 '14 at 10:18
  • I couldn't figure out, how to do it in that, so I just figured it would be easier to do it in the htaccess file. – Gunther Aug 28 '14 at 10:21
  • Trust me, it might be easier right now, but you'll soon have a bigger headache than if you start reading up on the rewrite API. – TheDeadMedic Aug 28 '14 at 10:32
0

This rewrite rule will surely work. Add this code to your .htaccess file. RewriteEngine On RewriteRule ^uni/([^/]*)$ /gallery/?university=$1 [L]

  • I tried your solution didn't work – Gunther Sep 1 '14 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.