简体   繁体   中英

htaccess removing part of url path and stay at base (at localhost)

I've gone through all QA here, but I am not getting it right.

I am using wamp and my site resides in a folder named 'site'.

I am trying to redirect this

http://localhost/site/public/foo/bar/

to

http://localhost/site/foo/bar/

using these rules:

RewriteEngine On
RewriteBase /site/
RewriteRule ^public/(.*)$ /$1 [L,R=301,QSA]

but it redirects to

http://localhost/foo/bar/

If I explicitly mention it in rule then it works.

RewriteRule ^public/(.*)$ /site/$1 [L,R=301,QSA]

Can I write a rule without explicitly adding /site/ ?

你可以试试这个吗?

RewriteRule ^public/(.*)$ $1 [L,R=301,QSA]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM