aerecords;10999746 wrote:Hey all i need help im building a web app in dreamweaver and need my app to run where the problem is i need it to be in the format of index.php?mod=(module name)&feature=(page where content is coming from)
it needs to be where ?mod= looks in the folder mods in the root directory for the corresponding name
and &feature= looks for the file matching the variable in the second part with the php extension. to make it easier to understand
Web Root
------------Modules
----------------------Calander (this is the variable for the first url parameter eg. index.php?mod=calander
---------------------------------newevent.php (this is the second url parameter eg. index.php?mod=calander&feature=newevent.
The reason for this is so that my code isn't exposed.
i want the index.php file to read something like
<?php
include ('header.php');
getContents();
include ('footer.php');
getContents being the function to place the content of the requested module on the page.
Any help would be greatley apreciated.
Hi there,
First I would say stay away from dreamweaver if you are using PHP as doing your manual coding yourself will help you understand what you are trying to achieve.
There are two elements you need if you want to run friendly URL's first of course is your web page structure to be correct and the second is a correctly compiled .htaccess file.
Your index.php would be better suited to look like the following example as it has more flexibility than the example you posted:
<?
$page = isset($_GET['p']) ? $_GET['p'] : 'home';
switch($page) {
/*----------------------- PAGES -----------------------------------*/
case 'aboutus':
$title = 'About us page';
$keyword = 'some, key, words';
$description = 'This is my about us page';
break;
default:
$title = 'Home page';
$keyword = 'some, key, words';
$description = 'This is my home page';
break;
}
include('include/header.php');
include(''.$page.'.php');
include('include/footer.php');
So the example above also allows you to dynamically update your meta data too; ensuring you place the following in your header file for them to work:
<title><?php echo $title; ?></title>
An example.
Now the .htaccess file. This part is easy but for you to understand I would recommend reading up about Apache server behaviour and MOD_rewrite to understand what the code is doing for you:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^robots\.txt$
RewriteRule ^([^/]+)/? index.php?p=$1
This should work fine for you above ensuring you call the file ".htaccess"
The function of your links will change. You should now use the following format:
old format: index.php?mod=calander
New format: http://www.foobar.com/calender
So your links may look like: /calender or ../calender
Hope that helps 🙂
Last thing : Google and the forum search facility is your friend, there is tonnes of info on this subject. 🙂