如何在url重写中隐藏子文件夹

编程入门 行业动态 更新时间:2024-10-26 08:22:45
本文介绍了如何在url重写中隐藏子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的网站是:www.mysite/subfolder/login/index.php

My site is : www.mysite/subfolder/login/index.php

我希望网址只是 www .mysite /登录/ index.php的。我尝试修改根文件夹中的.htaccess文件,如下所示:

I want the URL there to just be www.mysite/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)/.+)$ www.yourdomain/subfolder/login/$1 [L,NC]

您可以在此处看到更多示例和重写方式: https://wiki.apache / httpd /重写

You can see more examples and ways of rewriting here: wiki.apache/httpd/Rewrite

更多推荐

如何在url重写中隐藏子文件夹

本文发布于:2023-11-01 11:25:49,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   文件夹   如何在   url

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!