Changing header for PHP website - php

I am trying to make a website in PHP (I don't really have any experience in this). What I did was use an existing website that somebody created for me and just went about changing things in the .php files.
I had this in header.php:
<base href="http://old-domain.com/"; />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="stylesheet" type="text/css" href="css/default.css?v=4" />
<link rel="shortcut icon" href="favicon.ico" />
I just changed the 'old-domain' to 'new-domain'.
Now, my homepage of the 'new-domain' looks fine. But all other pages, like new-domain.com/help or new-domain.com/about give me a 404.
On the other hand, when I change the 'new-domain' back to 'old-domain', it displays my old website properly, so I guess this means that the code is alright.
What am I doing wrong? Do I need to set up new-domain.com/help, etc somewhere else?
Thank you.

Just check whether any other file contains the link www.old-domain.com and change it to www.new-domain.com.
I assume the project structure is the same.

because there is no seperate php file for those pages create seperate file for each like help.php and about.php and then include those in header

Related

Laravel 5 Hosting Asset Files

I have seen many questions here regarding Laravel 5 finding css and script assets. I have done what those answers suggest, mainly using a blade.php template and using either asset() or URL::asset, but sadly none of these work. I suspect something else is wrong here.
I am getting to my view directly, using http://[MyIP]/[ProjectName]/resources/views/[MyFile].blade.php in the address bar. My scripts and css are in the public folder, within directories javascript and css respectively.
When I load [MyFile].blade.php, which looks like so:
<title>My File</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<link rel="stylesheet" href="{{ URL::asset('css/font-awesome.min.css')}}">
<link rel="stylesheet" href="{{ URL::asset('css/animatemolly.css')}}">
<link rel="stylesheet" href="{{ asset('css/molly.css')}}">
<script src="{{ URL::asset('javascript/jquerymin.js')}}"></script>
It finds none of those. And in the served page, I get this error:
GET http://[MyIp]/[ProjectName]/resources/views/%7B%7B%20URL::asset('javascript/jquerymin.js')%7D%7D
It's like w/e Laravel service should be converting these into something useful isn't running at all? Do I need to install something further? I was under the impression that using it this way came with Laravel 5, according to this answer: Laravel stylesheets and javascript don't load for non-base routes... so I must be having some other problem, please advise.
You cannot go to your blade template directly, it must be rendered first by the templating engine. You usually do that in your controller.

CSS file isn't properly linked when I change the .html file to a .php

This problem is exclusive to the index.html file, and as I said before, the CSS that works when it's an html, stops working when the extension is changed. I inspected the ref link on both instances and when it's a php, the CSS files end up being the php file itself. I'm assuming that it maybe can't access the css for some weird reason? I'm not sure how that translates to only when it's a php. I've done the same procedure to other pages, and it works fine.
If it means anything, part of what stops working is the Foundation I'm using.
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Foundation</title>
<link rel="stylesheet" href="stylesheets/app.css" />
<link rel="stylesheet" href="stylesheets/main.css" />
<script src="bower_components/modernizr/modernizr.js"></script>
<script src="js/foundation/foundation.js"></script>
<script src="js/foundation/foundation.clearing.js"></script>
</head>
I also found that any href links stop working as well.
I guess it is delivered using a wrong MIME type. Try forcing CSS MIME type by setting the headers like below:
header("Content-type: text/css");
Moreover, make sure that, using PHP, you should execute using a server. i.e., the following URL is right:
http://domain/path/to/index.php
http://localhost/project/index.php
And not:
file:///c:/wamp/www/project/index.php
file:///c:/myproject/index.php
file:///c:/xampp/htdocs/index.php

Issue linking CSS to backend Zend Framework 1

I am working on a Zend Framework 1 application. It is successfully installed on my localhost and is working without any problems. However I've noticed that the css for the back end of the application is not working.
When I view the page source I can see the stylesheet has been loaded and can click on the link to it to view in the browser.
However the style is not applied to any of the elements on the screen and I do not understand why.
This is the layout file for the page: (adminstyle.css is not loading...)
<link href="/css/adminstyle.css" media="all" rel="stylesheet" type="text/css" title="default" />
<link rel="stylesheet" href="/css/smoothness/jquery-ui-1.10.2.custom.min.css">
<link rel="shortcut icon" href="images/favicon_2.ico" />
</head>
does anyone know what might be causing this issue? Apologies for the question if it seems stupid but I'm not really experienced with this sort of thing and I am trying to get to the bottom of it. Any help is much appreciated.
I can provide more details if required, I just do not want to post lots of unescessary snippets of code up.
Here is the right way to write links in zend framework cause with your way it will work just for the index/index , for other view you won't get the style css applied :
<link rel='stylesheet' type='text/css' href="<?php echo $this->baseUrl()."/css/style.css"; ?>" >
the same for your js files
hope it helps.

Is it good practice to add a php include of the head section in my pages?

I am creating my portfolio site and I am wanting to include the head section as a php include on my page. Reason being is because the site will have a fair few pages and I will want to make changes later on to things later on like tidying up the css files.
For example;
<head>
<?php include('head.php'); ?>
</head>
as opposed to all this below being shown on each and every page:
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/1140.css">
<link rel="stylesheet" href="css/ie.css">
<script src="js/vendor/modernizr-2.6.1.min.js"></script>
</head>
I just didn't know if this was good practice to do, as with this being my portfolio site, I need the code to be correct from the start also as they will probably look into the standard of it also.
What are your opinions and advice people? Thanks.
Yep, it's quite standard. But instead of writing:
<head>
<?php include('head.php'); ?>
</head>
you should put the tags inside head.php. I say it's better because what's inside head.php has no sense without the head tags, so they are kinda linked together. It's good practice to join things so linked into a single file without having to repeat open and close head tags for each page.
Actually, it's even good practice (and commonly used) to have header.php, body.php and footer.php files that has respectively:
header.php
<html>
<head>
...
</head>
<body>
body.php
...
footer.php
</body>
</html>
I'm doing that in my application but I've found that it's not a good idea, because you have many of your stylesheets, javascripts, etc in a php file including the head section and you'll have problems with including it in php files in nested folders. this problem is because of relative paths.
If you can use absolute paths then it's ok otherwise it's not a good idea ...
PHP Includes are used like this all the time. Any time that you have content that will be the exact same on every page, it is very helpful to use an include
This is an old topic but I use
<?php include_once("phpinclude/head.txt"); ?>
phpinclude is it's own folder and I keep the footer, header, and common place info in that folder. .js, and .css has it's own as well.
Edit: I use require now. I would rather have a code fail and die rather than give some random string. They are the same except one dies and the other will print out an error or random code. This is for people learning PHP, not old heads.

Using LESS css in Codeigniter

Is there a way to implement a LESS stylesheet in a codeigniter project without having to rely on sparks and Carabiner?
In the of my view in CI, I place the link to the LESS file, and the LESS.js file directly underneath, however when I view the site, CI doesn't recognize the .LESS file. I've tried using relative paths as well as hardcoding the the file directories directly, however nothing changes. Is there something I should try adding to my config file to load the LESS files properly?
My file structure for the CI project is as follows
application
controllers
views
system
js
less-1.2.2.min.js
plugins.js
css
style.css
style.less
As for my header, its based off of the html5 boilerplate, to save space I'll only include the relevant info.
application -> views -> layout.php
<meta name="viewport" content="width=device-width">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet/less" type="text/css" media="screen" href="css/style.less">
<script src="js/less-1.2.2.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" media="screen" href="css/style.css">
<!-- end CSS-->
Are you using mod_rewrite in httpd.conf? If so, you need to make sure that .less files are exempted.
RewriteCond %{REQUEST_URI} !(^alocalfarmCI/index\.php|\.png$|\.gif$|\.less$|\.js$|\.css$|/robots
One way to easily tell if this is your problem, type in a non-existent url within your site that ends in .less. If you see CI's error page, that means /index.php/ was inserted in the url.
If you're running with client-side (javascript) LESS, Codeigniter won't be involved in how LESS operates. Be sure that you've set the rel attribute appropriately when you're linking your LESS file in your views and that the less.js file is being loaded correctly.
<link rel="stylesheet/less" type="text/css" href="styles.less">
<script src="less.js" type="text/javascript"></script>

Categories