rewrite url for videos with dynamic links

Multi tool use
rewrite url for videos with dynamic links
I have a video sharing website where users upload their videos and get a link for the video, here is an example of the video link:
http://example.com/user/files/index.php?id=123&name=abc
the Url I want is
http://example.com/user/f/123/abc
Id parameter is the identifier (id) of the video and the name is optional.If a user forgot to write the name parameter ,then the URL will be like this
http://example.com/user/f/123
but it should still reach the destination . What should I put in my htaccess to achieve this?
1 Answer
1
Try this in your Root/.htaccess
file
Root/.htaccess
RewriteEngine on
RewriteBase /
#if the Requested filename is not a directory
RewriteCond %{REQUEST_FILENAME} !-d
#if the Requested filename is not a file
RewriteCond %{REQUEST_FILENAME} !-f
#if above conditions are true then rewrite the url
RewriteRule ^user/f/([0-9]+)/([a-zA-Z0-9]+)?/?$ /user/files/index.php?id=$1&name=$2 [NC,QSA,L]
Second capture group in the RewriteRule
is optional here so that your video URL can accept both, /123/
or /123/abc
.
RewriteRule
/123/
/123/abc
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Thanks it works but now I have a problem ,css stylesheet is not working, how to solve this?
– user4813771
Apr 21 '15 at 17:17