开发者

htaccess - Rewrite root folder?

开发者 https://www.devze.com 2023-03-12 05:59 出处:网络
I\'ve had a good look on Google but couldn\'t see any examples of my scenario... or none that I could understand lol.

I've had a good look on Google but couldn't see any examples of my scenario... or none that I could understand lol.

Here's my situation. I have a htaccess rewrite开发者_如何学Go that takes the url http://www.mydomain.com/advert and points to http://www.mydomain.com/adverts/juneadvert/index.php This works fine, however, I want all the source code paths (javascript, css etc) to use the /advert slug too. That way the true path is hidden from the user.

E.g. I dont want: http://www.mydomain.com/adverts/juneadvert/css/style.css

I do want: http://www.mydomain.com/advert/css/style.css

Is this possible?


All you need is just 1 line rule like this:

Options -Indexes -MultiViews +FollowSymLinks
RewriteEngine On

RewriteRule ^advert/((css|js)/.*)$ /adverts/juneadvert/$1 [L,NC]
0

精彩评论

暂无评论...
验证码 换一张
取 消