سؤال

How to limit to 4 the number of words in a slug using htaccess only?

from

exemple.com/hello-world-how-are-you

to

exemple.com/hello-world-how-are
هل كانت مفيدة؟

المحلول

This sounds like a problem you need to fix in your code/database, not via .htaccess. It will cause a lot of extra (useless requests). A rule that would accomplish this would for example be:

RewriteRule ^([^-]+(-[^-]+){3})-.*$ /$1 [R,L]
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top