For a second there I thought that mod_rewrite wasn’t actually enabled, but the host has confirmed that it actually is and still the rewrite doesn’t do anything!
Which means there’s something wrong with the actual RewriteRule line.
However to me it looks correct!?!?
Yes, you’ve not accounted for “site/” in your regex (assuming this is in the .htaccess in the DocumentRoot).
FWIW (not much), the - in a range definition is supposed to be the first character to avoid confusion over whether it’s a meta character or not. That said, I’ve never seen a case where having it in the last position causes any confusion (for mod_rewrite) so this is just a “word to the wise.”
The site is running under a subdirectory called /site/ on root and the .htaccess file is in there as well.
The contents of everything including the .htaccess is in the /site/ directory, which means I shouldn’t add the “site/” into the regex, not that I havn’t tried though!
…I’ve tried all combos and nothing at all works, it’s just too odd. I’m beginning to think it’s the actual server config now so will run some tests on another setup elsewhere to concur with these thoughts.
Put this in the DocumentRoot (above sites) and remove the code from your sites directory:
RewriteEngine on
RewriteRule ^sites/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([0-9]+)$ sites/index.php?var=$4 [R=301,L]
When you’re satisfied that this has resolved your problem, remove the R=301 which was there only to show you that the redirection has taken place as intended.
No. There must be something which we’re overlooking by assuming that it’s working.
I’ve probably already asked but have you run the test to verify that mod_rewrite is enabled (from the tutorial article linked in my signature)? Creating the three files and testing should take no more than 10 minutes.
After much head-ache, it seems it was a permissions thing, which I might add is much harder to find out when running mod_rewrite on a shared host where you don’t have access to all the logs.
Think it has been resolved now. (notice that first word there <–[“think”]- )