Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-28-2012, 01:52 PM   PM User | #1
mr_sarge
New to the CF scene

 
Join Date: Mar 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
mr_sarge is an unknown quantity at this point
ModRewrite help

Hi,

I'm trying to make site.com/home.php rewrited to site.com/site.php?pg=home so all my URL will be:

Code:
site.com/home.php
site.com/about.php
site.com/contact.php
etc..
instead of:
Code:
site.com/site.php?pg=home
site.com/site.php?pg=about
site.com/site.php?pg=contact
etc..
in my php code I have:
Code:
$pg= $HTTP_GET_VARS['pg'];
$pg = $pg.".php";
include_once $pg;
and my .htaccess is:
Code:
RewriteRule ^(.*)\.php$ site.php?pg=$1 [L]
But it does'nt work. "echo $pg" always return "site.php" instead of the page that was in the url... So the page make an infinite loop trying to include site.php inside site.php and apache make a 500 error.

I don't find my mistake...

Could someone give my a hint please?

Thank you
mr_sarge is offline   Reply With Quote
Old 03-30-2012, 12:41 PM   PM User | #2
mr_sarge
New to the CF scene

 
Join Date: Mar 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
mr_sarge is an unknown quantity at this point
I made it work this way:
Code:
RewriteRule ^([a-z]+)/?$ site.php?pg=$1 [L]
But it don't wan't to work if I add the php extension like before:
Code:
RewriteRule ^([a-z]+)\.php$ site.php?pg=$1 [L]
mr_sarge is offline   Reply With Quote
Reply

Bookmarks

Tags
htaccess php get_vars

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:36 PM.


Advertisement
Log in to turn off these ads.