user2952880
user2952880

Reputation: 23

Remove all folder name form url

Recently I have installed my site into a sub-folder of root of server.

So To remove folders name from URL i have used following htaccess code.

Options -Indexes
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?hostname.com$
RewriteRule ^(/)?$ user/site1/index.php [L] 

But the problem is that i am, also able to access my site Via

hostname.com/user/site1

How can i stop user accessing my site via "hostname.com/user/site1"

Please help

Upvotes: 1

Views: 46

Answers (1)

anubhava
anubhava

Reputation: 784898

You can have a new redirect rule for this:

Options -Indexes
RewriteEngine on
RewriteBase /

RewriteCond %{THE_REQUEST} /user/site1(\S*)\s [NC]
RewriteRule ^ %1 [R=302,L,NE]

RewriteCond %{HTTP_HOST} ^(www\.)?hostname\.com$
RewriteRule ^/?$ user/site1/index.php [L] 

Upvotes: 1

Related Questions