DemCodeLines
DemCodeLines

Reputation: 1920

PHP htaccess and include path

I have a .htaccess in my that has this line:

RewriteRule ^name/([^/]+)$ login/test.php?test=$1

So when the user types in "http://test.com/name/John", the server thinks of it as "http://test.com/login/test.php?test=John and displays the appropriate page. Now, the test.php file has an include path like "include("file.php");"

For some reason, this doesn't work...Does it have something to do with the htaccess file?

Please help!

Upvotes: 0

Views: 395

Answers (3)

Richard
Richard

Reputation: 4415

You need to use the full path to the file.

 $_SERVER['DOCUMENT_ROOT'] . "/folder/file.php";

The file login/test.php is not executed from the login folder, but from the web root.

Upvotes: 0

Sam Heuck
Sam Heuck

Reputation: 602

Check your include_path, if your application's root directory isn't in the include path, include() will check the calling script's parent directory for file.php

Upvotes: 0

John V.
John V.

Reputation: 4670

Including files in php shouldn't be affected by Rewrites, likely it is the contents of the include file that are the problem, and the urls inside of that file. For more help we'll need more info.

Upvotes: 1

Related Questions