代码之家  ›  专栏  ›  技术社区  ›  Tiago

用CSS和JS重写php访问规则

  •  2
  • Tiago  · 技术社区  · 7 年前

    我在将重写规则应用到页面时遇到了一些问题。

    我的方案如下:

    Assets (contains all subfolders with JS, CSS, IMG, etc)
    header.php
    footer.php
    index.php (that have all links to all other files -> index.php?id=page
    

    例如,我有以下页面:

    edit-language -> that opens the page index.php?id=edit-language
    

    edit-language/delete/X -> opens the same page above but with &delete=X -> both X are the ID
    edit-language/publish/X -> opens the same page above but with &publish=X -> both X are the ID
    

    RewriteRule ^edit-lang/?$ index.php?id=edit-lang [L]
    

    RewriteRule ^edit-lang/delete/(.*)$ index.php?id=edit-lang&delete=$1 [L]
    

    我的所有资产都加载在页眉和页脚PHP文件中,比如src=“assets/js/…”

    有人能帮我吗?谢谢!

    1 回复  |  直到 7 年前
        1
  •  1
  •   delboy1978uk    7 年前

    我猜一下-你在用相对链接?

    src="css/some.css"
    

    从当前文件夹中查看。由于您现在处于不同的文件夹级别,因此这些文件不可用,将被删除。

    src="/css/some.css"
    

    推荐文章