Jump to content

Recommended Posts

Hello,

 

I need help with mod re write all i am wanting is to change my dynamic address which is:

http://localhost/index.php?page=home.php

 

To

http://localhost/home/

 

and same for all my other pages for example

http://localhost/contact

http://localhost/prices

 

if you could please help that would be great

 

thanks, Mal

Link to comment
https://forums.phpfreaks.com/topic/73388-newbie-to-mod_rewrite-need-help/
Share on other sites

  • 2 weeks later...

no that doesn't work either

 

My included page doesn't display, css doesn't display and all the styles are all over hthe place

 

this is my code for index.php

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Welcome To Jedwater Caravan Park</title>
</head>
<link href="/css/menu.css" rel="stylesheet" type="text/css">
<link href="/css/style.css" rel="stylesheet" type="text/css">
<div align="center"><img src="/pictures/jednewlogo.png"></div>
<body>
<div id="container">
<ul id="navbar"> 
<li class="navbar <?php if($_GET['page'] == "contact.php") { echo "current"; } ?>"><a href="/contact/">Contact</a></li>
<li class="navbar <?php if($_GET['page'] == "about.php") { echo "current"; } ?>"><a href="/about/">About</a></li> 
<li class="navbar <?php if($_GET['page'] == "reviews.php") { echo "current"; } ?>"><a href="/reviews">Reviews</a></li>
<li class="navbar <?php if($_GET['page'] == "sitehire.php") { echo "current"; } ?>"><a href="/sitehire/">Site Hire</a></li> 
<li class="navbar <?php if($_GET['page'] == "prices.php") { echo "current"; } ?>"><a href="/sitehire/">Season Prices</a></li> 
<li class="navbar <?php if($_GET['page'] == "facilities.php") { echo "current"; } ?>"><a href="/sitehire/">Park Facilities</a></li> 
<li class="navbar <?php if($_GET['page'] == "home.php") { echo "current"; } ?>"><a href="/">Home</a></li> 
</ul>
</div>
<div style="clear:both;"></div>
</div>
<center>
<div id="main">
<?php
if(file_exists($page))
{ 
  include $page; 
}
else
{
echo "No Page Exists";
}
?>      
</div>
<div id="bottomcontainer">
<ul id="bottomnavbar"> 
<li class="bottomnavbar <?php if($_GET['page'] == "contact.php") { echo "current"; } ?>"><a href="/contact/">Contact</a></li>
<li class="bottomnavbar <?php if($_GET['page'] == "about.php") { echo "current"; } ?>"><a href="/about/">About</a></li> 
<li class="bottomnavbar <?php if($_GET['page'] == "reviews.php") { echo "current"; } ?>"><a href="/reviews/">Reviews</a></li>
<li class="bottomnavbar <?php if($_GET['page'] == "sitehire.php") { echo "current"; } ?>"><a href="/sitehire/">Site Hire</a></li> 
<li class="bottomnavbar <?php if($_GET['page'] == "prices.php") { echo "current"; } ?>"><a href="/prices/">Season Prices</a></li> 
<li class="bottomnavbar <?php if($_GET['page'] == "facilities.php") { echo "current"; } ?>"><a href="/facilities/">Park Facilities</a></li> 
<li class="bottomnavbar <?php if($_GET['page'] == "home.php") { echo "current"; } ?>"><a href="/">Home</a></li> 
</ul>
</div>
</body>
</html>

 

 

if you can see any errors in my index.php file that mighh be the reason behind my problems

 

 

Thanks, Mal

it defined when ethier entering it into the URL address bar, if you were wanting the page "contact" it would be

 

http://localhost/index.php?page=contact.php

 

also defined a hyperlink the hyperlink would be:

 

<a href="?page=contact.php">Contact</a>

 

is this the best way around including a file useing a template or is there a better way.

 

Thanks, Mal

 

thanks for your replys,

 

i have updated my index.php page to

 

 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Welcome To Jedwater Caravan Park</title>
</head>
<link href="/css/menu.css" rel="stylesheet" type="text/css">
<link href="/css/style.css" rel="stylesheet" type="text/css">
<div align="center"><img src="/pictures/jednewlogo.png"></div>
<body>
<div id="container">
<ul id="navbar"> 
<li class="navbar <?php if($_GET['page'] == "contact") { echo "current"; } ?>"><a href="/contact/">Contact</a></li>
<li class="navbar <?php if($_GET['page'] == "about") { echo "current"; } ?>"><a href="/about/">About</a></li> 
<li class="navbar <?php if($_GET['page'] == "reviews") { echo "current"; } ?>"><a href="/reviews/">Reviews</a></li>
<li class="navbar <?php if($_GET['page'] == "sitehire") { echo "current"; } ?>"><a href="/sitehire/">Site Hire</a></li> 
<li class="navbar <?php if($_GET['page'] == "prices") { echo "current"; } ?>"><a href="/prices/">Season Prices</a></li> 
<li class="navbar <?php if($_GET['page'] == "facilities") { echo "current"; } ?>"><a href="/facilities/">Park Facilities</a></li> 
<li class="navbar current <?php if($_GET['page'] == "/") { echo ""; } ?>"><a href="/">Home</a></li> 
</ul>
</div>
<div style="clear:both;"></div>
</div>
<center>
<div id="main">
<?php

include $_GET['page'];

?>      
</div>
<div id="bottomcontainer">
<ul id="bottomnavbar"> 
<li class="bottomnavbar <?php if($_GET['page'] == "contact.php") { echo "current"; } ?>"><a href="/contact/">Contact</a></li>
<li class="bottomnavbar <?php if($_GET['page'] == "about.php") { echo "current"; } ?>"><a href="/about/">About</a></li> 
<li class="bottomnavbar <?php if($_GET['page'] == "reviews.php") { echo "current"; } ?>"><a href="/reviews/">Reviews</a></li>
<li class="bottomnavbar <?php if($_GET['page'] == "sitehire.php") { echo "current"; } ?>"><a href="/sitehire/">Site Hire</a></li> 
<li class="bottomnavbar <?php if($_GET['page'] == "prices.php") { echo "current"; } ?>"><a href="/prices/">Season Prices</a></li> 
<li class="bottomnavbar <?php if($_GET['page'] == "facilities.php") { echo "current"; } ?>"><a href="/facilities/">Park Facilities</a></li> 
<li class="bottomnavbar <?php if($_GET['page'] == "home.php") { echo "current"; } ?>"><a href="/">Home</a></li> 
</ul>
</div>
</body>
</html>

 

and my htaccess to

 

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^(.*)$ index.php?page=$1 [L]
</IfModule>

now apache server is crashing and keeps crashing every time i try to load a page

 

errors from apache erro log:

Thu Nov 01 16:09:18 2007] [notice] Parent: child process exited with status 3221225725 -- Restarting.
[Thu Nov 01 16:09:18 2007] [notice] Apache/2.2.3 (Win32) PHP/5.2.0 configured -- resuming normal operations
[Thu Nov 01 16:09:18 2007] [notice] Server built: Jul 27 2006 16:49:49
[Thu Nov 01 16:09:18 2007] [notice] Parent: Created child process 10936
[Thu Nov 01 16:09:19 2007] [notice] Child 10936: Child process is running
[Thu Nov 01 16:09:19 2007] [notice] Child 10936: Acquired the start mutex.
[Thu Nov 01 16:09:19 2007] [notice] Child 10936: Starting 250 worker threads.
[Thu Nov 01 16:09:19 2007] [notice] Child 10936: Starting thread to listen on port 80.
[Thu Nov 01 16:09:26 2007] [notice] Parent: child process exited with status 255 -- Restarting.
[Thu Nov 01 16:09:27 2007] [notice] Apache/2.2.3 (Win32) PHP/5.2.0 configured -- resuming normal operations
[Thu Nov 01 16:09:27 2007] [notice] Server built: Jul 27 2006 16:49:49
[Thu Nov 01 16:09:27 2007] [notice] Parent: Created child process 13392
[Thu Nov 01 16:09:27 2007] [notice] Child 13392: Child process is running
[Thu Nov 01 16:09:27 2007] [notice] Child 13392: Acquired the start mutex.
[Thu Nov 01 16:09:27 2007] [notice] Child 13392: Starting 250 worker threads.
[Thu Nov 01 16:09:27 2007] [notice] Child 13392: Starting thread to listen on port 80.
[Thu Nov 01 16:09:30 2007] [notice] Parent: child process exited with status 3221225725 -- Restarting.
[Thu Nov 01 16:09:30 2007] [notice] Apache/2.2.3 (Win32) PHP/5.2.0 configured -- resuming normal operations
[Thu Nov 01 16:09:30 2007] [notice] Server built: Jul 27 2006 16:49:49
[Thu Nov 01 16:09:30 2007] [notice] Parent: Created child process 13524
[Thu Nov 01 16:09:30 2007] [notice] Child 13524: Child process is running
[Thu Nov 01 16:09:30 2007] [notice] Child 13524: Acquired the start mutex.
[Thu Nov 01 16:09:30 2007] [notice] Child 13524: Starting 250 worker threads.
[Thu Nov 01 16:09:30 2007] [notice] Child 13524: Starting thread to listen on port 80.

 

Thanks for any help, i'm trying to work it ou myself be having no joy.

 

Cheers, Mal

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.