I just built a sit in Codeigniter, but when I click on a menu item the stylesheet breaks and it displays all of the content broken out on the page.
http://marciabrownproductions.com/
I uploaded it to a test server and all the links works perfectly.But when I uploaded the finished site ot my clients server the css issue starts. Is there something wrong with my clients server? Or is there a problem with how I coded the site? Why does it work on one server, but not the other.
Thanks!
First, I recommend using absolute paths instead of relative paths when referencing your assets. At the moment, they are being picked up with the index.php included.
So, let's say your link is http://domain.tld/index.php/home/actors, you should be calling your assets from their actual URLs - http://domain.tld/index.php/_/css/style.css would not work, for example. http://domain.tld/_/css/style.css, however, would work. (That's just a sample URL.)
I'd also recommend removing the index.php from your links, simply by using the htaccess RewriteEngine, and removing index.php from your app's config file.
Have a look at how your current source is being generated in a browser (right-click, View Source) to see what I mean.
Update:
Based on your comment, that may be an htaccess issue. Check to see if your hosting provider supports it.
In the meantime, put the index.php back in the app's main config file. However, leave your CSS asset link as it is. Make sure all your asset links look like this:
<link href="http://marciabrownproductions.com/_/css/styles.css" rel="stylesheet" type="text/css" />
<script type='text/javascript' src='http://marciabrownproductions.com/_/js/jquery.validate.js'></script>
<script type='text/javascript' src='http://marciabrownproductions.com/_/js/effects.js'></script>
<link href="http://marciabrownproductions.com/_/css/bjqs.css" rel="stylesheet" type="text/css" media="screen" />
<script src="http://marciabrownproductions.com/_/js/bjqs-1.3.js"></script>
Your images are broken because their links are also including the index.php/home. You need to make sure that that is taken out. (What are you using to generate your links anyway?)
Related
Disclaimer: I haven't got a clue what I'm doing with PHP I'm just playing around with it.
I have my css file in a folder named CSS and then my header.php and footer.php in the main site folder. If i include the header.php in other directories I am just using:
<?php include('../header.php'); ?>
I know this isn't the way to do it however I don't know how to configure it probably (with a config.php file etc..) but my issue is, once the header's included in files in any directory of course it will look for the css/main.css file in that folder so I've tried doing the following:
<link rel="stylesheet" href="<?php echo $_SERVER['DOCUMENT_ROOT']. '/JAGS/css/main.css' ?>" />
When I use the php line in the body it displays the path
E:/xampp/htdocs/JAGS/css/main.css
but if I use it there in the link tag then doesn't work.
What seems to be my problem other than the fact I'm clueless with PHP. Is there something else I should be using? Is there something I need to do in my xampp config files?
Edit: By "doesn't work" I mean the styles are not being applied.
Edit 2: Inspecting shows the following:
<link rel="stylesheet" href="E:/xamppp/htdocs/JAGS/css/main.css">
I know there's an extra p on the end of xampp, this is actually what I have the folder named. Is it because it's not saying "localhost/JAGS/CSS/main.css"? If so what would be the reason for this?
Edit 3: Console shows error below:
Not allowed to load local resource: file:///E:/xamppp/htdocs/JAGS/css/main.css
Edit 4: Not using Laravel
Thank you
Why do you require the document root, you should just place a dot in front of it and set the base url in a meta tag.
<base href="yourdomain.com">
<link rel="stylesheet" href="./JAGS/css/main.css'/>
I am working on a webapplication that's running on a subdomain. In the code I used relative URL's all over the place. Nothing special, just the normal way to go.
I have just uploaded the site, but I can't find any file that I want to include. This, for example, is working now:
Site URL: sub.domain.com
CSS files are in: sub.domain.com/css/
Adding the following to the index.php **is working:**
<link rel="stylesheet" href="/css/styleSomething.css">
But including PHP files it the thing that is not working
Site URL: sub.domain.com
PHP Include files are in: sub.domain.com/inc/
Adding the following to the index.php is **not** working:
require_one(/inc/config.php)
If I change the URL's to start with a ./ or with no slash at all it will find the files for the homepage. But that's not going to work when the visitor navigets to a different page.
Am I missing some here of is this a problem with the hosting?
You can use the <base> tag to set the root URL for your site: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
The following should work for your example:
<base href="http://www.blah.com/yadda1/yadda2">
<link rel="stylesheet" href="css/styleSomething.css">
This will reference the stylesheet at http://www.blah.com/yadda1/yadda2/css/styleSomething.css.
If you are using PHP and using several URLs, place your base URL in a variable:
<base href="<?php echo $base_url; ?>">
If I understand correctly, you have the pages under /rel1 under the root of the server.
If so, try using /rel1/css/style.css.
I am trying to include a PHP file in another directory.
Here is my file structure
settings\
manage.php
website \
index.php
main.js
main.css
For manage.php
echo 'Welcome to the manager! Here is your website:';
include('../website/index.php');
index.php
<script src='main.js'></script>
<link rel="stylesheet" type="text/css" href="main.css">
So, when I load manage.php, I do not get main.js or main.css. How can I get this to work? Maybe include is not the right way to go? I cannot modify anything in the website folder.
[I know iFraming is a possible solution but I'm hoping to get another answer]
Since you cannot edit /website/ content you should could try this ugly code for a startup.
Add following just before include statement in your manage.php
echo('<base href="../website/">');
If it works for you, then you can think of sending a correct header with PHP before including a html file, instead of directly echoing a base tag.
Please consider comments of jeroen as down-to-earth solution and use frames
The problem here is that when the browser loads /settings/manage.php it will make requests for /settings/main.js and /settings/main.css which don't exist
You probably need to change your html in index.php to something like this:
<script src="/website/main.js"></script>
<link rel="stylesheet" type="text/css" href="/website/main.css">
Note I've made some assumptions about your URLs based on your directory layout so you may need to adjust my solution to make it work for you
Based on the comment below the question: If you want to include some functions / code for your users (instead of the other way around; you including user's stuff in your code), you should look into the auto_prepend_file directive.
Basically, you specify in your php.ini file that you want to prepend (as a require) a certain php file before the main file.
Edit: As you don't have access to php.ini but you can use a .htaccess file, you can put this in your .htaccess:
php_value auto_prepend_file "/path/to/your/file.php"
site example: http://ec2-107-22-119-73.compute-1.amazonaws.com/index.php/info/databases
Working Example: http://jscrollpane.kelvinluck.com/mwheel_intent.html
I cant get scrollwheel to work.
If you cant tell from the URL, my site is an expressionengine site. Using coldfusion and junk like that to build the pages.
anyone? (I tried searching for this issue, but no one seems to simply not be able to make scroll work.)
Ensure the paths to your JavaScript/CSS files are named appropriately and aren't throwing 404 errors.
The easiest way to ensure valid links to your assets is to use the {site_url} single global variable when linking assets in your templates:
<script src="{site_url}/script/jquery.mousewheel.js"></script>
<script src="{site_url}/script/jquery.jscrollpane.min.js"></script>
Which would result in the following:
<script src="http://example.com/script/jquery.mousewheel.js"></script>
<script src="http://example.com/script/jquery.jscrollpane.min.js"></script>
Since you're using ExpressionEngine's templates for your CSS — as opposed to flat files — you may want to give those template names a .css file extension.
So instead of:
<link rel="stylesheet" href="/index.php?css=site/master.v.1324329515" />
You'd have:
<link rel="stylesheet" href="/index.php?css=site/master.css.v.1324329515" />
This isn't absolutely necessary since EE will set the proper text/css MIME type based on the template type. However, it does make reading and debugging the source code easier, and is more of a standard practice.
Understandably, many beginners reference and borrow code from the Agile Records ExpressionEngine Theme that's available during new EE installations, so it's easy to recognize EllisLab's approach to markup and architecture — be it for the better or worse.
Bonus: remove the cache-busting timestamp (v.1324329515) in ExpressionEngine from CSS URLs, use the {path} variable instead of the {stylesheet} variable:
// With Cache-Busting String Appended
// http://example.com/index.php?css=site/master.css.v.1324329515"
<link rel="stylesheet" href="{stylesheet=site/master}" />
// Without Cache-Busting String
// http://example.com/index.php/site/master.css
<link rel="stylesheet" href="{path=site/master}" />
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.
I have a link like:
localhost/mywebsite/project?id=22
New link is something like
localhost/mywebsite/project/22/myproject.project
htaccess code:
RewriteRule ^project/([0-9]*)/.*\.project$ /project.php?project=$1 [L]
(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)
My root directory is localhost/mywebsite/
and my CSS file is in css/style.css
localhost/mywebsite/css/style.css
my htaccess
localhost/mywebsite/.htaccess
and my project.php file is in
localhost/mywebsite/project.php
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" />
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.
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"
but when i go live i should change all links to probably something like
href="/css/style.css"
this seems like lots of work
For your local version add
<base href="//localhost/mywebsite" />
to the head section
and for your live versions change it to
<base href="//your.domain.here" />
reference at http://www.w3.org/TR/html4/struct/links.html#h-12.4
you have to define the base path or the server view path in the connection.php and whenever u want that path, make that global. then that variable will b called and the css or images will take the whole path.
for example
$SVP="http://www.example.com/"
global $SVP;
echo $SVP;
so
Insert an image into the same file with the same relative path as the css href link, load the page in a browser, right-click the image in internet explorer, click properties and you should see where the relative path actually points to.