问题
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
回答1:
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]
来源:https://stackoverflow.com/questions/28281147/remove-all-folder-name-form-url