如何在url重写中隐藏子文件夹 [英] How to hide a subfolder in url rewriting
本文介绍了如何在url重写中隐藏子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的网站是:www.mysite.com/subfolder/login/index.php
My site is : www.mysite.com/subfolder/login/index.php
我希望网址只是 www .mysite.com /登录/ index.php的
。我尝试修改根文件夹中的.htaccess文件,如下所示:
I want the URL there to just be www.mysite.com/login/index.php
. I tried modifying the .htaccess file in the root folder as follows:
RewriteRule ^login\/index\.php$ /subfolder/login/index.php [L]
- 但问题在于它可以从登录文件夹中使用或访问CSS文件(style.css)。
--but the problem is that then it can't use or access the CSS file (style.css) from the login folder.
推荐答案
# fix js/images/css
RewriteRule ^.+?/((img|css|js)/.+)$ /subfolder/login/$1 [L,NC]
尝试在 htaccess
中添加它作为您的第一条规则。或者您可以使用
Try adding this as your first rule in htaccess
. Or you can use
# fix js/images/css
RewriteRule ^.+?/((img|css|js)/.+)$ http://www.yourdomain.com/subfolder/login/$1 [L,NC]
您可以在此处看到更多示例和重写方式: https://wiki.apache .org / httpd /重写
You can see more examples and ways of rewriting here: https://wiki.apache.org/httpd/Rewrite
这篇关于如何在url重写中隐藏子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文