rewrite rule quick question

I am trying to write a rewrite rule to go into .htaccess

I want to show a url like this:
http://www.domain.com/article/

but article is really article.php

how does this re write rule need to be written.
LVL 3
jbrashear72Asked:
Who is Participating?
 
caterham_wwwConnect With a Mentor Commented:
> but I need it to work with
/article/test/1

so you don't need to match /article only?

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^./]+)/ $1.php

Open in new window

0
 
jbrashear72Author Commented:
I tried the attached code below.
it works when I go to:

/article.php
and works with
/article

and works with
/article?test=1

but I need it to work with
/article/test/1

I am using the  $PATH_INFO to break out the URL.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(([A-Za-z0-9\-]+/)*[A-Za-z0-9\-]+)?$ $1.php
 
 
 
**********************************************************
 
$var_array = explode("/",$PATH_INFO);
would give:
 
$var_array[0] = "article.php"
 
$var_array[1] = test
 
$var_array[2] = 1

Open in new window

0
All Courses

From novice to tech pro — start learning today.