开发者

Clean up index files and place in directory?

Right now I have a assortment of 9 files (javascript, image, stylesheet, php) in the root开发者_如何学C directory of my web server. I would like too put all of these files in a directory called home (for home page). So now at this point I can view my home page at http://example.com/home.

I would like it so that when you visit http://example.com/ it points to the files in the home directory.

I am using php so my first attempt was to create a index.php in the root and include the index from home. This breaks relative URLS within styles, javascript, and includes. To combat this I prepended my includes with $_SERVER['DOCUMENT_ROOT'].'/home/. More problems arise when I try to redirect http://example.com/home to http://example.com/.

Is their any better way of doing this, possibly with .htaccess?


Yes, if your server supports mod_rewrite, you could probably add a RewriteRule:

RewriteRule /(.*) /home/$1 [R,L]


In your Apache httpd.conf change the DocumentRoot to your "home" folder.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜