2

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

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 Commented Aug 14, 2015 at 8:27

1 Answer 1

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]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.