Here is my .htaccess rule
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
It will construct 'public' for all the requests.
After using this it works for good for
site.com/home , site/blog
but while i start to use
site/blog/data
it does not load the css as it is a sub directory
How can i rewrite the url to make this work
RewriteRule ^(.*)$ public/blog$1 [L]
For the first probablity
ie, domain.com/blog the css will be site.com/css/style.css
and while in the next probablity
ie, domain.com/blog/data the css will be site.com/blog/css/style.css
which is expected as site.com/css/style.css for the second probablity also
How can i do this ?
Since you don't want to show me your code I can only guess here...
I suppose the problem's that you include the css file like that:
<link rel="stylesheet" type="text/css" href="css/style.css"/>
This means the path is relative to the current URL. What you need to do to make it work on every "level" is use an absolute path or at least one that's relative to the site root (domain)
<link rel="stylesheet" type="text/css" href="/css/style.css"/>
Or just use the Laravel asset()
function that generates a full url
<link rel="stylesheet" type="text/css" href="{{ asset('css/style.css') }}"/>
Or even one step further, use HTML::style()
to generate the full include code
{{ HTML::style('css/style.css') }}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.