0

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!

7
  • what's in the include file ? debug it, print the $_GET params in the included file and again in test.php. Commented Feb 12, 2012 at 0:58
  • the include file is the head file which is supposed to print a head block. it works in every other file except for this file. So it works in index.php in the home directory but not in this directory. Commented Feb 12, 2012 at 1:01
  • maybe you call it from some subdirectory :/ try include("../file.php"); Commented Feb 12, 2012 at 1:05
  • when I do include("../file.php"); it prints out the whole css file that is being included instead of using its values. I know the css should be used as <link... but I am doing something different. Commented Feb 12, 2012 at 1:12
  • now i don't understand anymore :D you get error by including the other file or what? Commented Feb 12, 2012 at 1:14

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

if there was a problem with the contents of the file included, then it wouldn't work anywhere else. It works everywhere else when included, its just this file that messes it up.
if the included file uses, for example, a parameter with the same name - it will run over the parameter in test.php and you won't see this side effect in other pages that don't use the same parameter. that's why I'm suggesting to debug!
0

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

4 Comments

That problem is solved now. But I am now facing another one: I have this line of code in my body style: background-image: url('<? echo $a951168545["backpic"]; ?>'); and backpic is the url to an image but the body isn't loading that for some reason. How can I fix it?
The code you just posted is attempting to utilize php short tags. If short tags have been enabled in php.ini, it should look like this url("<?= $pic ?>"); if not, you need to use url('<?php echo ... ?>);
but this problem is the same as the previous problem because this code works elsewhere but not here
i just checked, <? echo $a951168545["backpic"]; ?> has no value because echo "hello"; prints out hello. so there is a connection problem.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.