php - Using .htaccess to clean a URL -
this question has answer here:
i've looked around, , things either seem overkill, or i'm not understanding something.
i've got following urls:
http://cms.dev/article.php?post_id=6
and replace them with
http://cms.dev/article/6/
i've got following code:
rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^\.]+)$ $1.php [nc,l]
however, cleans urls /admin.php
/admin
.
what best way clean url, keep .php removed other pages?
you can use:
rewriteengine on rewritecond %{request_filename} !-d rewritecond %{document_root}/$1\.php -f [nc] rewriterule ^([^/]+)/([0-9]+)/?$ /$1.php?post_id=$2 [l,qsa] rewritecond %{request_filename} !-d rewritecond %{document_root}/$1\.php -f [nc] rewriterule ^(.+?)/?$ /$1.php [l]
Comments
Post a Comment