【问题标题】:htaccess - Rewrite root folder?htaccess - 重写根文件夹?
【发布时间】:2011-09-13 19:39:52
【问题描述】:

我在 Google 上看得很清楚,但看不到任何我的场景示例……或者没有我能理解的示例,哈哈。

这是我的情况。我有一个 htaccess 重写,它采用 url http://www.mydomain.com/advert 并指向 http://www.mydomain.com/adverts/juneadvert/index.php 这很好用,但是,我希望所有源代码路径(javascript、css 等)也使用 /advert slug。这样,真正的路径就对用户隐藏了。

例如我不想要: http://www.mydomain.com/adverts/juneadvert/css/style.css

我确实想要: http://www.mydomain.com/advert/css/style.css

这可能吗?

【问题讨论】:

  • 对此表示歉意。我已经勾选了工作答案。从现在开始,我会更加努力——感谢开发人员抽出时间帮助我:)

标签: .htaccess mod-rewrite url-rewriting


【解决方案1】:

您只需要这样的 1 行规则:

Options -Indexes -MultiViews +FollowSymLinks
RewriteEngine On

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

【讨论】:

  • 感谢 anubhava - 你是救生员! :)
  • @user287212 和@Tomgrohl,不客气。感谢您发现我的回答很有用。
猜你喜欢
  • 2021-11-20
  • 2015-05-18
  • 2015-11-11
  • 1970-01-01
  • 1970-01-01
  • 2015-09-27
  • 1970-01-01
  • 2021-07-01
  • 1970-01-01
相关资源
最近更新 更多