I am looking over my code for 3 hours and I don’t get it. I hope that you can help me.
I have a wordpress blog with Custom Post Types and Advanced Custom Fields installed. Its working pretty nice. I use a basic filter function over the custom fields as described here: http://www.advancedcustomfields.com/resources/creating-wp-archive-custom-field-filter/
To filter the custom fields I use the get-parameters form the url. So the url comes in the form like:
www.domain.tld/?post_type=movie&land=usa&typ=love&actor=kidman
Now I would like the have a pretty url in the form:
www.domain.tld/movie/usa/love/kidman
And hier comes the issue, I cant get the .htaccess right 🙁
My Code is:
AddHandler php56-cgi .php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^movie/(.*)/(.*)/(.*)$ /?post_type=movie&land=$1&typ=$2&actor=$3 [L]
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
It’s not working. The result is a 404. I believe is’s a “wordpress-thing” that I don’t get.
If I change the code to:
RewriteRule ^movie/(.*)/(.*)/(.*)$ http://www.domain.tld/?post_type=movie&land=$1&typ=$2&actor=$3 [L]
It works as a normal redirect.
If I change it to
RewriteRule ^movie/(.*)/(.*)/(.*)$ file.php/?post_type=movie&land=$1&typ=$2&actor=$3 [L]
where file.php is a non wordpress file, it works as well (It shows the content of file.php)
It seems that I’am not able to “call” a wordpress-specific file like index.php.
I hope you can help me, and thanks that you read through my non native english 😉
Greetings from germany
Dominik
I solved my problem on my own 🙂
As always, the solution is pretty simple if know where to look.
I had a deep look into: http://codex.wordpress.org/Rewrite_API/add_rewrite_rule and http://codex.wordpress.org/Rewrite_API/add_rewrite_tag
Finally the coin dropped.
First I deleted every custom code I made in the .htaccess cause its not the location to solve my problem.
I added the following to my functions.php
After you edited your function.php don’t forget to save the permalinks in your wordpress settings.
Now I have access to the “query_vars” in the template:
or the functions.php:
It works perfect 🙂
Thank u anyway and have a nice weekend
Dominik