1

How can I Hide index.php and rewriting URL parameters

http:example.com/www/index.php?page=admin&action=login

as

http:example.com/www/admin/login

I have hide index.php using the code mentioned below (Helped from URL) which makes URL as:

http:example.com/www/?page=admin&action=login

My htaccess file code

  Options +FollowSymLinks -MultiViews
  # Turn mod_rewrite on
  RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?$1 [L,QSA]

  RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
  RewriteRule ^ %1 [R=301,L]

But I need like this:

http:example.com/www/admin/login

If any body knows, that will be a great help.Thank you

Community
  • 1
  • 1
  • 1
    change `RewriteRule ^(.*)$ index.php?$1 [L,QSA]` to `RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]` now you will be able to get request uri in `$_GET['rt']` like `$_GET['rt'] = www/admin/login/`, and then just explode it with `/` and use that – manjeet Aug 14 '15 at 08:27

1 Answers1

0

You can use these rules in /www/.htaccess:

DirectoryIndex index.php
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /www/

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ %1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^([^/]+)/([^/]+)/?$ index.php?page=$1&action=$2 [L,QSA]

RewriteRule ^(.+)$ index.php?$1 [L,QSA]
anubhava
  • 761,203
  • 64
  • 569
  • 643