create website without an home page - php

I would like to create a website without an home page
example for home page will be
www.lawyer.com
instead i would like to present only clean urls like this
www.lawyer.com/lawyer-in-us-chicago
www.lawyer.com/lawyer-in-us-denver
etc...
my first question is
how will it affect on my SEO?
do i must have an home page like
www.lawyer.com
even if i don't have any content to put on it
my second question is
how should i redirect from
www.lawyer.com to www.lawyer.com/chicago-lawyers

Just put a blank page called index.html, and inside it write the following JavaScript code (inside <script></script> tag):
window.location.href = "www.lawyer.com/chicago-lawyers";

Related

PHP-SQL: If ?page=1 in the URL is pre-set to the homepage, how are other '?pages' set?

In the thedigicraft online tutorial for developing dynamic websites, the main example traverses between pages using the browser's response to this: ?page=#. It also works on my project; when I type http://localhost/trying/?page=1, it goes to the project's homepage. I'd like to know how one sets what page opens with ?page=2 and other numbers. In the tutorial's project example, he then uses the _get array to define defaults, but there's no explanation for how his ?page=2 opens up that project's about page, for example. What am i missing - would appreciate any light on this.
In your example page is a GET parameter. The page being loaded is whatever is defined in the server's configuration. In apache it is documentroot. https://httpd.apache.org/docs/2.4/mod/core.html#documentroot
So your page probably is index.php. In that page you could have something simple like:
if($_GET['page'] == 2) {
echo '<title>Other page</title>';
} else {
echo '<title>Home page</title>';
}
Which would display Home Page as the title for every page unless http://localhost/trying/?page=2 is loaded.
You can extrapolate this concept to SQL queries for content loading etc..

URL path with universal header is not working

I have three pages on my localhost 1 is my index page,2 is my universal header page which is under includes folder of and 3 is my html file which is under html folder.The header file is included in both the index file and html file like that...
for index.php-include("includes/header.php");
for html.php-include("../includes/header.php");
and my header has the link of index.php page that is (./index.php)
Now my questions is that when i open my index page and click on link of index page from my header it takes me to same index.php page but when in open html.php page and then click index.php page link from header it does not go to index.php page but it goes to this page-
(localhost/educational%20website/html/index.php) how to solve that.
And i also want to know that write now i am on localhost but when i make my site live is there any need to change the paths because i am making around 150 pages with your technique plaese so please answer me that kind of technique that is used for both localhost and on live
Your are including paths relatively, use a (absolute) base path in your index.php to fix this:
include_once($_SERVER['DOCUMENT_ROOT'].'/includes/header.php');
One way is to define a variable or a constant for the site's url in the header.php file. Then in all your other pages, you could just use this variable/constant when you need to mention the other urls.
Eg(put this as first line in your header.php file):
define('SITE_URL', 'http://localhost/educationalwebsite');
Here, we have defined a constant named SITE_URL. Then in other pages, you are already including this header file. Isn't it? So, this constant will be available in your index.php, html.php and other pages.
And suppose for a link in your html.php file(to point to the index.php), you could use it like this:
Home
If you want to include link to the html.php file residing inside html folder, it would be like:
HTML
By using this way, if you are uploading the whole site to a live server, you only need to change one line, ie. the first line in header.php, where we have defined the SITE_URL constant. Just change it's value to the new URL of the home directory of your website.
Hope this helps

jQuery not working in a PHP include

I am building a website that utilizes a template and brings each "content" page in through an include statement. On one page, I am using wt-rotator which is a jQuery script based slide show so to speak. My problem is that the page that I am wanting to include runs the script perfectly, but when I try to view that page through the main template using the include, there is no slideshow. This is the code that makes the "include" work:
<?
include "/home/content/82/7960182/html/alliantwellness/contentfiles.php";
$pid = $_GET["pid"];
if ($pid == "") {
$pid = 0;
}
?>
That part is at the very top of the index.php page. Then this:
<?
//Main Content including Navigation fills in here
include "/home/content/82/7960182/html/alliantwellness/content/" . $content[$pid];
?>
is what I use to call the page. The contentfiles.php page is just an array of "content" pages that are stored in a folder called "content".
Any ideas on why the slideshow works outside the template, but not inside?
Here are the URL's so you can see what I am talking about:
http://www.alliantwellness.com
http://www.alliantwellness.com/content/home.php
I think you need to remove this line:
<script type="text/javascript" src="http://www.alliantwellness.com/scripts/jquery.wt-rotator.js"></script>
from index.html. That file is not a Javascript file, it looks like it's a duplicate of the index.html file. You're already loading jquery.wt-rotator.min.js on a different line of the file, and that's the correct JS.
I also wonder why you're loading both http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js and http://www.alliantwellness.com/scripts/jquery-1.7.1.min.js, why do you need to load two different versions of jQuery from different locations? But home.php loads both of them and it seems to work.

several subpages with same topbar

I have a webpage with several subdirectories for example /search or /friends. Each of this subpages has its own javascript and css files. Now I want all this pages to have the same topbar so if I wanted to change the topbar I would only have to do this in one single place.
What's the common way of doing this? Simple php drops out because of the several scripts and css files. My idea was to call a php script via ajax on each subpage and append the returning string to the body element with jquery's append method but this doesn't seem very clean to me.
How does facebook handle this? Facebook's topbar doesn't even blink when clicking an internal link.
Thanks.
What about using an header.php in all the pages where you want to show your top bar?
To do this just create a file with top bar and save it as header.php and then in your index.php just place include('header.php'); repeat second step for each page where you want to have your top bar.
header.php
// top bar stuff
echo '<ul><li>Link</li><li>Link</li></ul>'; //etc
Other Pages
<?php
include 'header.php';
?>

Can I hide a portion of my URL?

I asked a simialr question earlier about using jquery and hashtags but what I really need to do is after a successful login redirect the user to the home page (home.php) Ideally I want to load my header with my menu only once and then update my main div tag with the contents of home. This will let me load the menu bar just once and not after every page load. I'm currently calling the home page like so:
if(isset($success) {
header('Location: menu.php?home');
exit();
}
Is it possible to hide the menu.php portion of the URL to the end user or is there a better way?
Thanks
Maybe look at apaches mod_rewrite. Tutorial
Is it possible to hide the menu.php portion of the URL to the end user?
No.
is there a better way?
You can use a mod_rewrite rule to rewrite /home to /menu.php?home.
what about renaming menu.php to index.php & using it like
if(isset($success)) {
header('Location: /?home');
exit();
}

Categories