开发者

redirect all links to include a segment in front of the main url

I setup a local website using mamp, there are other sites I run in development on the same mamp install and I use links on my site like <a href="/about">About</a开发者_Python百科>

It will direct the user to http://localhost/about, but I need it to direct to http://localhost/chuck/host

chuck is the folder that this site is within, file path: /Applications/MAMP/htdocs/chuck

Is there a way in the htaccess file that any link automatically is redirected with /chuck plugged into the front of the url?

I hope this is possible, so I do not have to go thru every file and put /chuck in front of (for this example), /about, to make it http://localhost/chuck/about


RewriteEngine on
RewriteRule (.*) /chuck$1 [nc,l]

Basically, anything after the %{http_host} will be put after /chuck. This will redirect EVERYTHING to have /chuck in front of it.

This will have to be put in the /path/to/htdocs folder. However, it will also make it impossible to visit any other site you may have hosted there.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜