I'd like to make it so that when i enter http://website.com/5/sometitle it opens /displayvideo.php?id=5&title=sometitle, this currently works with the following code
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/(.*)$ /displayvideo.php?id=$1&title=$2 [L]
However I'd also like to make it so that when i go to http://website.com/5 it will go to /displayvideo.php?id=5 I've tried this by adding
RewriteRule ^(.*)$ /displayvideo.php?id=$1 [L]
however that just ends up with a bunch of weird crap like being unable to open actual files, like /somefile.php, as it will think the somefile.php should be an id tag by the rewriterule
Doing this also results of the other rewrite rule to become invalid because it automatically thinks /displayvideo.php?id=$1 is a tag of the new rule.
Basically every page on the site becomes a 500 internal server error
Anyone knows how to fix this? Thanks
This should do it.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/(.+)$ /displayvideo.php?id=$1&title=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)$ /displayvideo.php?id=$1 [L]