php - Shortening URL using .htaccess -


my folder structure is:

modules

  • admin

    • index.php
  • login

    • login.php
    • signup.php
  • articles

    • articles.php

my current url is:

localhost/modules/admin/index.php

localhost/modules/login/login.php

localhost/modules/articles/articles.php

i want change to:

localhost/index

localhost/login

localhost/articles

since beginner in using .htaccess file, pls me how can change url using .htaccess file

your folder structure makes difficult have universal rule should able use these rules.

rewriteengine on  rewritecond %{request_filename} -f [or] rewritecond %{request_filename} -d rewriterule ^ - [l]  rewriterule ^(index)/?$ /modules/admin/$1.php [nc,l,qsa] rewriterule ^(login|articles)/?$ /modules/$1/$1.php [nc,l,qsa] 

Comments

Popular posts from this blog

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -