php - Rewrite folders and Remove the trailing slash at the end -
i'm trying have 1 url without trailing slash @ end of urls/folders, @ same time want re-write folder use dynamic pages, example:
if have:
mydomain.com/folder mydomain.com/folder/
and
mydomain.com/folder/second mydomain.com/folder/second/
then want open "mydomain.com/folder" , "mydomain.com/folder/second" , urls should open dynamic pages. trying, not work, crash page:
rewriteengine on rewriterule ^(.*)/$ /$1 [l] rewriterule ^(.*)$ includes/category.php?url=$1&pagetype=category [l] rewriterule ^(.*)/(.*)/$ /$1/$2 [l] rewriterule ^(.*)/(.*)$ includes/subcategory.php?url=$1&pagetype=subcategory [l]
what doing wrong? can me run right syntax please?
you need redirect trailing slash url's instead of rewriting them. need add conditions rules:
rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)/$ /$1 [l,r=301] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)$ /includes/category.php?url=$1&pagetype=category [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]+)/([^/]+)$ /includes/category.php?url=$1&pagetype=subcategory [l]
Comments
Post a Comment