Why i can't get an image to work. I'm trying this:
background-image: url(jBootstrap/images/ui-icons_222222_256x240.png);
and it doesn't work. When i'm trying to access it trought URL i get an error:
Asset [stylesheets/jBootstrap/images/ui-icons_222222_256x240.png] was unable to be processed.
Can't get any images, tried in many variations of directories and still doesn't work. When i'm doing this on plain html-css it works perfectly, but not in laravel. What am I doing wrong ?
btw, i'm using Basset if it helps.
EDIT 1
Also including the additional information about a partial structure of my public folder and html link generated by basset:
public/
stylesheets/
jBootstrap/
images/
ui-icons_222222_256x240.png
main.css it contains the background-image...
when including the css file, in source code i see:
<link rel="stylesheet" type="text/css" href="http://localhost/Job/worker/myapp/public/7n3C5wypAmTi8VT8/application/stylesheets/main.css" />
Edit 2
Adding my public/.htaccess file:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Edit 3
Tried another way:
public/stylesheets/main.css
public/stylesheets/abc.jpg
in main.css I have code: body { background-image: url('abc.jpg') } and i'm getting nothing ...
Please help, struggling 2 days now ...
Found the problem... It was Basset package, it wat required to put $collection->apply('UriRewriteFilter'); into configurations.
I would naturally assume that one (or both) things are incorrect here:
Your .htaccess file is not checking for existing files when rewriting. Check to see if RewriteCond {%REQUEST_FILENAME} !-f exists in that file.
You are not requesting your background image from the root, i.e. absolutely. Try requesting the resource using a leading slash. For example, instead of calling foo.png, try calling /foo.png.
Try using setArguments('../') on your collection
'collections' => array(
'application' => function($collection) {
$collection->add('../vendor/twitter/bootstrap/less/bootstrap.less')->apply('Less');
$directory = $collection->directory('assets/stylesheets', function($collection) {
$collection->add('main.css');
})->apply('UriRewriteFilter')->setArguments('../')->apply('CssMin');
}
),
This did the trick for me.
Related
My old domain: domain.com
My laravel project in: domain.com/laravel/public
It's working well, but I don't want see public in URL.
I add new .htaccess file to my root laravel folder (domain.com/laravel/.htaccess) with:
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
When I access to domain.com/laravel, my jQuery path is: domain.com/js/jquery.min.js
When I access to domain.com/laravel/public, my jQuery path is: domain.com/laravel/public/js/jquery.min.js
I don't want move all files in public folder to root folder, because really more files there.
Best regards,
I read more answers in more website, almost their said move all files in public folder to root folder of Laravel application.
It's not good if we have more files there, so, I was try with some way and finally, I just move index.php and .htaccess file to root application.
It's working well, I just change some code when using HTML::script, HTML::css and {{ asset }}
As normal, we using HTML::css('style.css'), I just add public before, like this: HTML::css('public/style.css')
I hope it helpful for someone.
Best regards.
This is my current solution:
<IfModule mod_rewrite.c>
RewriteCond $1 !^(public)
RewriteRule ^(.*)$ /public/$1 [L]
</IfModule>
You have to add a rewrite condition.
I'm going crazy here! I'm trying to learn Laravel and pretty URLs just don't work.
I have enabled mod_rewrite from my apache config file, I have set AllowOverride to All in my user config file and I have the following in my .htaccess file in public folder of Laravel installation:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
I enter http://localhost/~user/lara/public/index.php/users it works, but with http://localhost/~user/lara/public/users I get 404 Not Found error
The requested URL /Users/user/Sites/lara/public/index.php/users was not found on this server.
You can see that the redirection works fine, as public/users have turned into public/index.php/users but it says not found, even though when I manually enter public/index.php/users it show me the output.
I have read all the related questions on SO, none of the worked for me!
This is most likely caused by the fact that you are changing the document root during a request. From the looks of your URL (with the ~user segment) you are using mod_userdir or something similar, and what these types of plugins do it allow you to map a given URL prefix to a document root that is not the normal one for the server.
As such, you sometimes run into issues like this where the right .htaccess file is found, but its rewritten URL is against the original document root rather than the modified one and so your index.php file cannot be found (maybe, to be honest I don't really know, this is all conjecture). This is also why going directly to index.php/users works - the problem isn't the setup per se, but the mixing of rewrite rules and the change of the document root.
As such, the fix is to use a RewriteBase line, ad the following to the .htccess file:
RewriteBase /~user/lara/public/
I want to rewrite URLs from my-custom-url.com/abc/admin/anypage/ to my-custom-url.com/def/admin/anypage/
I have already taken a look to http://httpd.apache.org/docs/2.0/misc/rewriteguide.html, chapter "Moved Document Root"
I opened .htaccess in root directory (which refers to http://www.my-custom-url.com/), looked for <IfModule mod_rewrite.c> and included the following code:
RewriteEngine on
RewriteRule ^/abc/admin/$ /def/admin/ [R]
I tried also:
RewriteRule /abc/admin/ /def/admin/
Both didn't work. What's wrong?
First of all, take shure, that you are allowed to use .htaccess and modRewrite
To take shure:
write some nonsenss in your .htaccess eg asdfasdf as fasdfa
This should exec an Internal Server Error When you get the error, delete the nonsenss .-)
Then try this:
RewriteEngine on
RewriteRule ^test-the-world/$ http://www.google.de [L]
RewriteRule ^abc/admin/$ /def/admin/ [R,L]
Then open the URI's:
http://example.com/test-the-world/ -> when successful you go tho google.de
http://example.com/abc/admin/ ->when successful you go to /def/admin/
First of all - I have searched quite a bit for an answer in stackoverflow and via google but haven´t been successfull so far to find a possible solution any advice would be greatly appreciated.
problem is:
I have a page
www.mypage.com
and controll the language displayed via a GET parameter lang
-> www.mypage.com/index.php?target=1&lang=en
Now a client has registered a domain at united-domains (www.mypage.it) and wants me display the italian version of the page whenever the domain www.mypage.it is requested.
The provider united-domains offers a solution called URL-HIDING which basically seems to pass the the request to a URL+folder structure I provide (like www.mypage.com/lang/it - according to the specifications of united-domains it has to be a folder structure and may not be a file)
solution so far:
Calls to the domain: www.mypage.it will be maped to www.mypage.com/lang/it/ via the URL-HIDING option.
there an .htaccess file rewrites the REQUESTS to the actual target:
RewriteEngine on
## check if query string contains NOT 'lang='
## (lang might be changed by user after initial request)
RewriteCond %{QUERY_STRING} !lang=
## redirect to page
RewriteRule ^(.*)$ http://www.mypage.com/index.php?target=1&lang=it
## check if query string contains 'lang='
RewriteCond %{QUERY_STRING} lang=
## Keep the existing query string using the Query String Append flag
RewriteRule ^(.*)$ http://www.mypage.com/index.php? [QSA]
Problem is of course: the CSS, javascript, image,... files are included with an relative path
<link href="scripts/style.css" rel="stylesheet" type="text/css">
<script src="scripts/media.js" type="text/javascript">
<img src="images/logo.jpg">
PDF
therfore the relative request scripts/style.css is mapped to http://www.mypage.com/lang/it/scripts/style.css
I am sadly stuck the the URL-HIDING mechanism of united-domains and changing every relative path the /scripts/media.js is not an option as I´d have to change quite a bit of code.
Does anyone have a solution for this (my .htaccess knowledge is not the best I am afraid)
Couldn´t I just remove lang/it/ from EVERY request and additionally check if the QUERY_STRING contains the string lang= and if it does simple add ?lang=it
thanks to all that have taken the time to read so far - if anyone has a suggestion I´d be more than grateful !
stay well,
matthias
This seems to do the trick !
in folder:
www.mypage.com/lang/it/
I put:
RewriteEngine on
## redirect if just folder is requested
RewriteCond %{REQUEST_URI} ^/lang/it/$
RewriteRule ^(.*)$ http://www.mypage.com/index.php?target=1&lang=it
## otherwise redirects if file does not exist
RewriteCond %{DOCUMENT_ROOT}/lang/it/$1 !-f
RewriteRule ^(.*)$ http://www.mypage.com/$1 [QSA]
I've come across a problem which i cant seem to figure out, i use the jQuery address plugin to store history and enable deep linking, and a typical url after a click would look like this:
http://mysite.com/#!/page
Problem here is i need rid of the last / so i need it to look like this:
http://mysite.com/#!page
I'm using plugin version 1.2 - the latest is 1.4. When i use 1.4 my hashbang #! disappears..
Anyone know why? even so, the updated version produces the same problem.
Reasons to fix this are i use 301 redirects to 'Pretty URL's' if an ?_escaped_fragment_= is requested. So this:
http://mysite.com/data/#!page1
would become:
http://mysite.com/data/page1
currently it does this: mysite.com/data//page1
here is the .htaccess rewrite:
<IfModule mod_rewrite.c>
RewriteEngine on
# Rewrite current-style URLs of the form 'index.php?url=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
</IfModule>
and here is some relevant PHP i use on page load:
if ($fragment = $_GET['_escaped_fragment_']) {
// OPTION 1: if Google is reqesting an '_escaped_fragment_=' page, then redirect to a clean URL
header("Location: $base/$fragment", 1, 301);
exit;
}
Any help on how to make this situation better is appreciated.. I don't want 'use the HTML5 History API' as ive explored this option already.
This line of code can help!
$.address.strict(false);