0

i want to remove/hide the subdirectory "sites" from the url

/profile
  /sites
    login.php
    register.php 
index.php
.htaccess

this: http://localhost/profile/sites/login

to this http://localhost/profile/login

currently i am using this to hide the .php extension

htaccess:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php[\s?] [NC]
RewriteRule ^ %1 [R=301,L]

# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/profile/$1.php -f
RewriteRule ^(.+?)/?$ /profile/$1.php [L]
2

1 Answer 1

1

As per your comment on the question, you could simply include the login.php from the base directory to the /sites/login.php. This will make this file run like the one in the base directory. Also see options like include_once(), require(), require_once().

I suggest you use require_once(), and don't see the need for modifying .htaccess file.

require_once('../login.php');

UPDATE: as per your comment on this answer, try this in the .htaccess file

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^sites/(.*)$ http://www.yoursite.com/$1 [R=301,L]

See this link for reference.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks, but each file have their own content (index,login,register) i will include more pages into sites folder and for that reason i want to hide that directory this is my site iwnew.hol.es but this one doesn't have the directory sites is just /login.php,registro.php,index.php

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.