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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -