I need to redirect all urls with matching keyword, regardless of position in link, to one single url on same site.
Example:
Links with word "book"
www.domain.com/booklovers.php
www.domain.com/booksforall.php
www.domain.com/bestbooksonamazon.php
www.domain.com/somethingaboutbooks.php
to be redirected to one single url on same domain,
www.domain.com/books.php
For now, I am focusing on
RewriteEngine On
RewriteRule ^.*book.*$ /books.php [L,QSA]
but it is not working. I tested same expression
^.*book.*$
in tester on http://tools.netshiftmedia.com/regexlibrary/ and it works, but in .htaccess it does not work. I am reading various answers here and learned a lot on other examples, but I can not find nothing for my case.
Try something like this after making sure AllowOverride is set to All in your virtualhost config and that mod_rewrite is enabled:
RewriteEngine on
RewriteBase /
RewriteRule book books.php [L,QSA]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With