久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

URL 重寫后缺少 CSS 文件和圖像

Missing CSS file and images after URL rewrite(URL 重寫后缺少 CSS 文件和圖像)
本文介紹了URL 重寫后缺少 CSS 文件和圖像的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試使用模式重寫制作用戶友好的 URL.我的問題是,在為我的 URL 提供名稱"之類的類別后,當我使用新 URL 調用頁面時,它無法加載 CSS 文件或圖像.

I'm trying to make user friendly URL using mode rewrite. My problem is, that after giving category like 'name' to my URL, when I call the page using new URL, it can't load the CSS file or images.

我有一個鏈接:

localhost/mywebsite/project?id=22

localhost/mywebsite/project?id=22

新鏈接類似于

localhost/mywebsite/project/22/myproject.project

localhost/mywebsite/project/22/myproject.project

htaccess 代碼:

htaccess code:

RewriteRule ^project/([0-9]*)/.*.project$ /project.php?project=$1 [L]

(它可能不是 100% 正確,但我現在無法訪問我的代碼,所以我只是寫了這個,它在原始源代碼上運行良好)

(it might not be 100% right but I don't have access to my code right now so I just wrote this and it works fine on the original source)

我的根目錄是 localhost/mywebsite/

My root directory is localhost/mywebsite/

我的 CSS 文件在 css/style.css

and my CSS file is in css/style.css

localhost/mywebsite/css/style.css

localhost/mywebsite/css/style.css

我的 htaccess

my htaccess

localhost/mywebsite/.htaccess

localhost/mywebsite/.htaccess

我的project.php文件在

and my project.php file is in

localhost/mywebsite/project.php

localhost/mywebsite/project.php

所以在項目頁面中,我可以使用相對路徑訪問 CSS 文件,

So in the project page I have access to CSS file by using relative path,

<link href="css/style.css" rel="stylesheet" type="text/css" />

但是當我使用重寫的 URL 頁面時找不到 CSS 文件.

but when I use rewritten URL page can't find the CSS file.

我還沒有域名,所以不能使用絕對路徑和域名!它可以是任何東西.

I can't use absolute path with domain name because I don't have domain yet! and it can be anything.

一種方法是按照類似問題的建議使用域的相對路徑本地主機/我的網站/project.php當我在本地運行腳本時,我的根目錄是本地主機所以css鏈接應該看起來像

one way is to use relative path to domain as suggested on the similar questions localhost/mywebsite/project.php and when i run my script localy my root directory is localhost so css link should look like

href="mywebsite/css/style.css"

href="mywebsite/css/style.css"

但是當我上線時,我應該將所有鏈接更改為可能類似于

but when i go live i should change all links to probably something like

href="/css/style.css"

href="/css/style.css"

這似乎有很多工作

推薦答案

為您的本地版本添加

<base href="http://localhost/mywebsite" />

到頭部部分

對于您的實時版本,請將其更改為

and for your live versions change it to

<base  />

參考 http://www.w3.org/TR/html4/struct/links.html#h-12.4

這篇關于URL 重寫后缺少 CSS 文件和圖像的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Action View Helper in Zend - Work around?(Zend 中的動作視圖助手 - 解決方法?)
Is this a good way to match URI to class/method in PHP for MVC(這是將 URI 與 PHP 中用于 MVC 的類/方法匹配的好方法嗎)
Where do I save partial (views) in Zend Framework, to be accessible for all Views in my App?(我在哪里保存 Zend Framework 中的部分(視圖),以便我的應用程序中的所有視圖都可以訪問?) - IT屋-程序員軟件開發技術
Having a single entry point to a website. Bad? Good? Non-issue?(有一個網站的單一入口點.壞的?好的?沒問題?)
Is MVC + Service Layer common in zend or PHP?(MVC + 服務層在 Zend 或 PHP 中常見嗎?)
Hello World example in MVC approach to PHP(PHP MVC 方法中的 Hello World 示例)
主站蜘蛛池模板: www.日本三级| 久久中文字幕一区 | 五月婷婷激情网 | 国际精品鲁一鲁一区二区小说 | 在线日韩精品视频 | 日本精品视频在线观看 | 在线第一页 | 日韩一区在线播放 | 日韩a| 日韩电影中文字幕在线观看 | 九九伊人sl水蜜桃色推荐 | 男女羞羞视频大全 | 午夜tv免费观看 | 91色视频在线观看 | 国产精品亚洲一区二区三区在线 | 亚洲成年在线 | 亚洲高清视频一区二区 | 国产黄色av电影 | 精品国产久 | 91资源在线 | 久草在线免费资源 | 亚洲精品91 | 久久亚洲欧美日韩精品专区 | 不卡一区| av片在线免费看 | 干干干操操操 | 国产午夜精品久久久久免费视高清 | 欧美一区二区网站 | 国产精品日韩欧美一区二区三区 | 1区2区视频 | 国产乱码精品一品二品 | 男人天堂网址 | 一区视频在线 | 91精品国产麻豆 | 精品1区2区 | 日韩精品福利 | 精品一区二区久久久久久久网站 | 久久婷婷香蕉热狠狠综合 | 96国产精品久久久久aⅴ四区 | 美人の美乳で授乳プレイ | 艹逼网|