9 Replies - 2610 Views - Last Post: 02 April 2013 - 09:43 AM

#1 DreamInNodes  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 02-April 13

Apache redirecting

Posted 02 April 2013 - 07:52 AM

Hi everyone,

I need a little help on a beginners issue.

I have two directories; 'web' and 'back'
'web' is accessible to the public and contains css files and images. 'back' contains the php scripts.
Now in order to make pages accessible I have all pages in the 'web' folder using inlude() on the main php script in 'back'.
Is there any more efficient way to redirect using apache?

Thanks.
Fuchz

Is This A Good Question/Topic? 0
  • +

Replies To: Apache redirecting

#2 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5247
  • View blog
  • Posts: 27,071
  • Joined: 10-May 07

Re: Apache redirecting

Posted 02 April 2013 - 07:53 AM

If I understand what you are asking, I wouldn't use a redirect for this. I would just simply suggest using the correct absolute path when you point to the php script.
Was This Post Helpful? 0
  • +
  • -

#3 DreamInNodes  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 02-April 13

Re: Apache redirecting

Posted 02 April 2013 - 07:57 AM

Is there no alternative? It is a little annoyance having to create a php file for each new page I'd like to publish. I'd rather have apache point to to main.php while preserving the $_SERVER["PHP_SELF"] variable. Sorry if I'm not clear enough, I'm not that content on this subject.
Was This Post Helpful? 0
  • +
  • -

#4 BenignDesign  Icon User is offline

  • holy shitin shishkebobs
  • member icon




Reputation: 6018
  • View blog
  • Posts: 10,444
  • Joined: 28-September 07

Re: Apache redirecting

Posted 02 April 2013 - 07:58 AM

Using an include() isn't redirecting. You're simply including the code from one file in the code from another. You're taking the code in file.css and file.html and essentially adding them to the code in file.php. That's what include() does. Does that make any sense at all?
Was This Post Helpful? 0
  • +
  • -

#5 DreamInNodes  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 02-April 13

Re: Apache redirecting

Posted 02 April 2013 - 08:00 AM

I know that the include() function does not redirect. Thats what I'm trying to use apache for.

Actually I'm trying to point, not redirect.
Was This Post Helpful? 0
  • +
  • -

#6 BenignDesign  Icon User is offline

  • holy shitin shishkebobs
  • member icon




Reputation: 6018
  • View blog
  • Posts: 10,444
  • Joined: 28-September 07

Re: Apache redirecting

Posted 02 April 2013 - 08:02 AM

After reading your response to no2pencil, I thinkI have a better understanding of what you mean. I misunderstood your original question.

However, you shouldn't need to create a new PHP file for every page of your site. That kind of defeats the purpose in scripting.

There are several ways to set up your file.php to pull content from somewhere else. Are you using a database at all? Or even a text file to hold your site data? Or are you setting up individual html files for each page as well?
Was This Post Helpful? 0
  • +
  • -

#7 DreamInNodes  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 02-April 13

Re: Apache redirecting

Posted 02 April 2013 - 08:06 AM

main.php essentially includes() a file containing the global markup for all pages, it also includes() a file containing the content specific for the requested page ofcourse.
Now instead of creating php files to include main.php, I'd like apache to point to it.

I do not use a database, the internal sitemap is stored in a xml file.
Was This Post Helpful? 0
  • +
  • -

#8 DreamInNodes  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 02-April 13

Re: Apache redirecting

Posted 02 April 2013 - 08:14 AM

I just found this

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]



I think this is what I need
Was This Post Helpful? 0
  • +
  • -

#9 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5247
  • View blog
  • Posts: 27,071
  • Joined: 10-May 07

Re: Apache redirecting

Posted 02 April 2013 - 09:00 AM

View PostDreamInNodes, on 02 April 2013 - 10:57 AM, said:

I'd rather have apache point to to main.php

Apache sets two configurations for a given website (vhost). The root directory & the index file. What you are trying to do is not best handled by redirecting. If you used the webserver to redirect that directory, the entire page would have 'wonky' effects. You are trying to over-solve the situation.

& if creating php pages is too difficult, then crease one page & dynamically handle the content.

View PostDreamInNodes, on 02 April 2013 - 11:14 AM, said:

I just found this
...
I think this is what I need

That's an .htaccess file. If that fixes your situation, then I guess I didn't understand what the problem was.
Was This Post Helpful? 0
  • +
  • -

#10 DreamInNodes  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 02-April 13

Re: Apache redirecting

Posted 02 April 2013 - 09:43 AM

well I tried the rewrite method and it didn't work as expected so I think you understand me correctly. The PHP_SELF variable didn't specify the orginal URI anymore, and I need it to make php include the right content. Maybe I should try query names next.

correction: a query string
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1