0

I have a custom post whose name is "babysitter".

I wrote this in my .htaccess:

RewriteRule ^babysitter/?$ /index.php/some-page/ [QSA,L]  

In layman terms, if url matches hostname.com/babysitter or hostname.com/babysitter/ go to hostname.com/index.php/some-page.
The strange behaviour I get is that this doesn't work (I mean RewriteRule is not matched) and I get a 404 error but even stranger is that this doesn't work even for strings starting with the first letters of babysitter and are substrings of it for example:
baby or bab or babys.
Instead it works if I write ababy or everything else which doesn't begin with custom post name:

RewriteRule ^ababysitter/?$ /index.php/some-page/ [QSA,L] 
RewriteRule ^ababy/?$ /index.php/some-page/ [QSA,L] 
RewriteRule ^abc/?$ /index.php/some-page/ [QSA,L]
RewriteRule ^cba/?$ /index.php/some-page/ [QSA,L] 

For all the rules just above urls:
hostname.com/ababysitter
hostname.com/ababy hostname.com/abc
hostname.com/cba
bring me to hostname.com/index.php/some-page which is what I want.

IS THIS A BUG IN WORDPRESS?

Basically what I am trying to achieve is that, if "babysitter" is a custom post:
hostname.it/babysitter gives me a page;
hostname.it/babysitter/4567 gives me the post page;

  • 2
    Is your rule above or below WordPress’ in your htaccess? – Jacob Peattie Oct 22 '17 at 10:13
  • It's inside it. Inside #BEGIN Wordpress #END Wordpress – Ferex Oct 22 '17 at 10:16
  • 1
    the code inside these tags will be erased on the next flush. then you have to put your code outside. And put it before then it applies before wordpress ones. – mmm Oct 22 '17 at 10:29
  • Tried it but didn't work. I completely removed wordpress stuff from htaccess and wrote just my directives. Nothing changed. – Ferex Oct 22 '17 at 14:25

Your Answer

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

Browse other questions tagged or ask your own question.