Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

.htaccess redirect subdirectory as query string in php

0

47 views

This is hard to explain, so hopefully I'm understood in my question.

(1) I want to create "SEO friendly" links that remove the query string from a web site. There is only one variable, let's call it "page". Here is the following code for my .htaccess file.

Options +FollowSymLinks

RewriteEngine On
RewriteRule ^(.*)$ index.php?page=$1

This works in providing the proper redirect. So /applications/ will send to index.php?page=applications.

(2) My index.php will include a view page based on the value of $_GET['page']. Here is some sample code below:

switch ($_REQUEST['page']) {

    default:
    include ("home.php");
    break;

    case "apps":
    include ("apps.php");
    break;  

}

There seems to be no problems so far.

(3) Let's make apps.php an exact copy of home.php. home.php loads just fine, but apps.php will not load linked CSS and JScript pages. When apps.php is loaded, it thinks it is in the /apps/ directory. To load the linked pages, I would need to insert a "../" in front of the file name. Then it displays correctly.

So my question is-- How can I properly write the .htaccess file so the home.php and apps.php page can be identical files and produce identical results, instead of the apps.php file being treated as if it were in the /apps/ directory?

asked June 25, 2011 2:06 am CDT
posted via StackOverflow

0 Answers

Be the first to answer this question

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions