I was wondering if this was possible in mod_rewrite, and if anyone knows the syntax for it.
Browser receives:
http://example.com/video/my-first-vid/
mod_rewrite redirects to:
http://example.com/#/video/my-first-vid/
Thanks!
It seems you can't use mod_rewrite for redirecting to /#/video/my-first-vid/ as the # sign is urlencoded and it will redirect to http://example.com/%23/video/my-first-vid/ which obviously isn't what you're looking for. I tested this couple of days before on Apache 1.3.
You may create a separate script(s) for redirection. Add a new rules for this:
RewriteRule ^video/?$ /redirector.php?page=video [NC,L,QSA]
RewriteRule ^video/(.*)$ /redirector.php?page=video&subpage=$1 [NC,L,QSA]
But you might also need to parse the query string manually as it could be smth like:
/video/my-first-vid/?refID=test
Here's some simple example on PHP:
<?php
$page = (isset($_REQUEST["page"])) ? trim($_REQUEST["page"]) : "";
$subPage = (isset($_REQUEST["subpage"])) ? trim($_REQUEST["subpage"]) : "";
// setting the redirect URL, your conditions here
if ($page == "video")
{
$url = "/#/video/" . $subPage;
}
else
{
$url = "/"; // some default url
}
header("Location: " . $url);
exit;
?>