I try to understand how to manage subdomains in Apache (mod_rewrite module).
On this website:
http://htaccess.madewithlove.be/
This link below:
http://www.sub.tst.com/foo/bar.php
Under this rule:
RewriteRule (.*)bar(.*)$ $1oxo$2 [PT]
Returns:
✔ The new url is http://www.sub.tst.com/foo/oxo.php
But under following rule (or any other similar):
RewriteRule (.*)tst(.*)$ $1oxo$2 [PT]
It returns an error:
✖ This rule was not met.
I want to redirect links with subdomains to proper subfolders (to tst.com/sub/foo/bar link - if it exists), so I think I just have to cut www.sub.tst.com/foo/bar.php into 2 chunks, where 'sub' and '/foo/bar.php' I put after 'tst.com' (and remove '.php' extension from the end of it), but so far regex is not working on rewrite rules as I expect (and as I test it on php).
What is wrong? How to get it right? How to test it, before I use it on my website?