...

View Full Version : .htaccess redirect question



GO ILLINI
10-14-2005, 11:13 PM
I have a php include section in my site using this format:
http://site.com/css/index.php?page=pagename
I was wondering if there was a way, using .htaccess, to redirect this:
http://site.com/css/contact.php
to:
http://site.com/css/index.php?page=contact
I want this because my template is on index.php along with a menu and other things and ?page= is included in a box in the middle of the page.

Thanks,
GO ILLINI

nikkiH
10-14-2005, 11:23 PM
I think you're looking for mod_rewrite.

GO ILLINI
10-14-2005, 11:42 PM
how do I usae that? is that a php or a .htaccess solution? If it is .htaccess solution is it one like where you can redirect an entire directory instead of typing out all the filenames? like
Redirect /olddir/ http://newsite/
?

nikkiH
10-14-2005, 11:45 PM
Apache.
Yes.
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

See the part about RewriteRule.

GO ILLINI
10-15-2005, 12:08 AM
so RewriteRule /hosting/(.*) /hosting/?page\%3d$1 [R,NE] would go in my .htaccess?
I tried that but it didn't work.
I have absolutely no expierence with this.

nikkiH
10-17-2005, 03:03 PM
Did you turn rewrite on?
i.e.
RewriteEngine on

See this tutorial (http://www.4webhelp.net/tutorials/misc/mod_rewrite.php).

GO ILLINI
10-17-2005, 11:12 PM
thank you for the help but I have found a way taht I understand better.
using php to define a var in the template and then seeing if the var exist on the actual page.
eg:
template.php:

<?php $pageCheck = "1" ?>

links.php:

<?php
if($pageCheck=="1") { }
else {
header("Location: index.php?page=links")
}
?>
(just used links page as an example.)
This will not be hard as there only going to be about 10 pages in the directory.

nikkiH
10-18-2005, 03:12 AM
Lucky you, only 10 pages. ;)
Glad you found a solution.

/ has over 120 pages in some of her sites

GO ILLINI
10-18-2005, 03:25 AM
ohh ya the site has about 250 pages total. I have like 5 seperate "sites" with subdomains included. I run a personal, css, forum, freak of the week(dont ask), web hosting, and like 2 more.
I have 1 domain with 26 subdomains total.
But this is only a mini site thing. Its part of the hosting site.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum