php - Using .htaccess to clean a URL -


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

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -