|
Posted by Justin Koivisto on 01/10/06 02:21
davegoogleflash@dexcard.com wrote:
> I'm sure this is a simple one, but I haven't been able to find it
> specifically covered in my looking through google...
>
> I'm fairly new to PHP and need to set up a simple procedure for a
> dynamic website I'm wrapping up. Each "page" has a unique code
> associated to it that is used to pull it from the MySQL database.
> Example:
>
> www.mysite.com/index.php?thepage=home
>
> ... would open the "home" page. But what I really need it to do is pass
> the variable using a typical URL like this:
>
> www.mysite.com/home
>
> Now I'm pretty sure I can pull this off with help from the .htaccess
> file, but I run into a dead end from there. How can I configure the
> .htaccess file to take what is after the "/" sign and pass it as the
> $thepage variable to my index.php page always sitting on the root?
alt.apache.configuration is a good group for this type of thing...
Here is out of one of my .htaccess files:
RewriteEngine On
RewriteRule ^/?$ x.php [L,NS,QSA]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f
RewriteRule .* - [PT]
RewriteRule ^([^/]+)(/([^/]+))?(/([^/]+))?(/([^/]+))?(/([^/]+))?/?$
x.php?d1=$1&d2=$3&d3=$5&d4=$7&d5=$9 [L,NS,QSA]
Request:
example.com/this/is/my/home/page/
Result (spaces for easy reading):
x.php?d1=this &d2=is &d3=my &d4=home &d5=page
Relative uris used in links, images, etc. fail (need to be absolute or
at least start with "/")
--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com
[Back to original message]
|