Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Server Side Programming > PHP Programming
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 10-21-2009, 09:56 AM
  #1
sticks464
Soldier (Level 11)
 
Join Date: Jan 2009
Posts: 127
iTrader: (0)
sticks464 is an unknown quantity at this point
Clean Url

I have spent the last two days trying to find what rewrite rules to use in .htaccess to create clean url's using wampserver. My url currently is
Code:
http://localhost/test/index.php?id=home
I would like it to read
Code:
http://localhost/test/home
Other pages all display the same with the id changing as each page is displayed.
Nothing I try seems to work in wampserver.
sticks464 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-22-2009, 12:42 AM
  #2
Horus_Kol
Mod of the Underlay
 
Horus_Kol's Avatar
 
Join Date: Jun 2002
Location: At a desk, hooked up and ready to rock
Posts: 17,242
iTrader: (0)
Horus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of light
what do you have at the moment?

Something like the following in your .htaccess should work:

Code:
RewriteEngine On

RewriteRule     ^/test/(.*)$                         /test/index.php?id=$1                        [QSA,L]
That will only apply to pages in the test folder though...
__________________
Personal Blog (and photos): HorusKol
Articles on Programming and Development (PHP/HTML/CSS, C/C++, more): RandomTweak

The great secret that no SEO agent wants you to hear: if you build your website using w3c accessibility guidelines and your content is written for people, you will do better for longer in search engines than any other method...
Horus_Kol is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-22-2009, 01:21 AM
  #3
sticks464
Soldier (Level 11)
 
Join Date: Jan 2009
Posts: 127
iTrader: (0)
sticks464 is an unknown quantity at this point
Sorry, that doesn't do anything unless I omit the space between the $ and /
then i get an error
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
sticks464 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-22-2009, 09:07 AM
  #4
scoutt
Mister Admin to you
 
scoutt's Avatar
 
Join Date: Jul 2001
Posts: 30,730
iTrader: (0)
scoutt is a jewel in the roughscoutt is a jewel in the roughscoutt is a jewel in the rough
Internal errors are on the server, look for the error_log to see the error, you may not beable to use a htaccess file. Try this

RewriteRule ^/test/(.*) index.php?id=$1 [L]
__________________
Have a Script or Snippet you want to share?

WWW Standards: HTML 4.01, CSS2.1, CSS3, XHTML 1.0
PHP Standards: PHP Standards
scoutt is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-22-2009, 10:28 AM
  #5
sticks464
Soldier (Level 11)
 
Join Date: Jan 2009
Posts: 127
iTrader: (0)
sticks464 is an unknown quantity at this point
This is what my error log says
Code:
[Thu Oct 22 09:04:54 2009] [error] [client xxx.x.x.x]PHP Notice:  Undefined index: id in C:\\wamp\\www\\test\\index.php on line 22
[Thu Oct 22 09:21:50 2009] [error] [client xxx.xxx.x.xxx] client denied by server configuration: C:/wamp/www/HNAP1
[Thu Oct 22 09:21:53 2009] [error] [client xxx.xxx.x.xxx] client denied by server configuration: C:/wamp/www/TEADevInfo
[Thu Oct 22 09:21:56 2009] [error] [client xxx.xxx.x.xxx] client denied by server configuration: C:/wamp/www/
Line 22 of index.php is
PHP Code:
if (in_array($_GET['id'], $pass)) { 
The code used to display pages is
PHP Code:
    <div class="wrapper">
      <!--main page content goes here -->

<?php
    
// Define our array of allowed $_GET values
        
$pass = array('home','services','media','testimonials','bio','contact');
            
    
// If the page is allowed, include it:
        
if (in_array($_GET['id'], $pass)) {
            include (
$_SERVER['DOCUMENT_ROOT'] . 'test/pages/' $_GET['id'] . '.php'); 
        } 
        
    
// If there is no $_GET['id'] defined, then serve the homepage:
        
elseif (!isset($_GET['id'])) {
            include (
$_SERVER['DOCUMENT_ROOT'] . 'test/pages/home.php'); 
        }

    
// If the page is not allowed, send them to an error page:
        
else {
                
// This send the 404 header
                    
header("HTTP/1.0 404 Not Found");
                
// This includes the error page
                    
include ($_SERVER['DOCUMENT_ROOT'] . 'test/inc/error.php');
        }

?>

    </div>
sticks464 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-22-2009, 07:17 PM
  #6
scoutt
Mister Admin to you
 
scoutt's Avatar
 
Join Date: Jul 2001
Posts: 30,730
iTrader: (0)
scoutt is a jewel in the roughscoutt is a jewel in the roughscoutt is a jewel in the rough
because you haven't defined this variable

$_GET['id']

Try this
PHP Code:
if (in_array($_GET['id'], $pass) AND !empty($_GET['id'])) { 
__________________
Have a Script or Snippet you want to share?

WWW Standards: HTML 4.01, CSS2.1, CSS3, XHTML 1.0
PHP Standards: PHP Standards
scoutt is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-22-2009, 08:05 PM
  #7
sticks464
Soldier (Level 11)
 
Join Date: Jan 2009
Posts: 127
iTrader: (0)
sticks464 is an unknown quantity at this point
This is still in the error log
Code:
[Thu Oct 22 18:53:46 2009] [error] [client xxx.x.x.x]PHP Notice:  Undefined index: id in C:\\wamp\\www\\test\\index.php on line 22
Using this in .htaccess
Code:
RewriteEngine On
RewriteRule ^/test/(.*)$ /test/index.php?id=$1
PHP Code:
<?php
    
// Define our array of allowed $_GET values
        
$pass = array('home','services','media','testimonials','bio','contact');
            
    
// If the page is allowed, include it:
        
if (in_array($_GET['id'], $pass) AND !empty($_GET['id'])) {  
            include (
$_SERVER['DOCUMENT_ROOT'] . 'test/pages/' $_GET['id'] . '.php'); 
        } 
        
    
// If there is no $_GET['id'] defined, then serve the homepage:
        
elseif (!isset($_GET['id'])) {
            include (
$_SERVER['DOCUMENT_ROOT'] . 'test/pages/home.php'); 
        }

    
// If the page is not allowed, send them to an error page:
        
else {
                
// This send the 404 header
                    
header("HTTP/1.0 404 Not Found");
                
// This includes the error page
                    
include ($_SERVER['DOCUMENT_ROOT'] . 'test/inc/error.php');
        }
?>
sticks464 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-25-2009, 09:44 PM
  #8
Horus_Kol
Mod of the Underlay
 
Horus_Kol's Avatar
 
Join Date: Jun 2002
Location: At a desk, hooked up and ready to rock
Posts: 17,242
iTrader: (0)
Horus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of light
and the URL you are testing with?
__________________
Personal Blog (and photos): HorusKol
Articles on Programming and Development (PHP/HTML/CSS, C/C++, more): RandomTweak

The great secret that no SEO agent wants you to hear: if you build your website using w3c accessibility guidelines and your content is written for people, you will do better for longer in search engines than any other method...
Horus_Kol is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-27-2009, 11:45 PM
  #9
sticks464
Soldier (Level 11)
 
Join Date: Jan 2009
Posts: 127
iTrader: (0)
sticks464 is an unknown quantity at this point
Url is
Code:
http://localhost/test/index.php?id=home
sticks464 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart
 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 12:10 AM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.