Why does my page not display?


#1

Hi,
I have 5 web pages at the root of my folder called for example:

index.php
about.php
contact.php
order.php
home.php

All of the pages are called by the index.php using GET method.

I also have a folder called about which contains the following file:

profiles.php

I have rewritten my URLs with MOD_rewrite in a .htaccess file which you can see below:

RewriteEngine On Rewritebase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^robots\.txt$ RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]

Everything works fine when I navigate through contact, order and home. But when I select book it gives me the following message:

Index of /about
[ICO] Name Last modified Size Description
[DIR] Parent Directory -
[ ] profiles.php 26-Mar-2012 17:15 1.3K
Apache/2.2.20 (Ubuntu) Server at mysite Port 80

I have a few links on the about.php page also that point to http://www.mysite/about/profiles

which obviously do not work either

Any help will be great? :slight_smile:


#2

Because the page doesn’t exist? at least it doesn’t from what’s listed above.


#3

How can we see “BOOK” or how that page is called without seeing some code.
You mention the other pages “HOME”, “ORDER”, “CONTACT”, etc… NO “BOOK”…

This is a PHP “code” helping site… Give us some code to fix… LOL…


#4

I thought I listed it above:

The file “profiles.php” is inside the folder called “about”

So physically the file is there. I know its an issue with my rewrite rule but cant figure it out.


#5

So, your statement: “But when I select book it gives me the following message:” says that you select an option “book”. We do not see that in any of your posts. Also, this is a code site, not a server site. We need to see the code that is failing to be able to fix it.

Lastly, what are you trying to do in the .htaccess code? What are you trying to rewrite? You see, we can decode your .htaccess code and figure it out, but, what does that matter if we can not see how you are calling your pages.

Help us help you!


#6

Ok guys, im sorry I made some typos there:

I have reposted everything below for you with the correct content and my php code:

I have 5 web pages at the root of my folder called for example:

index.php
about.php
contact.php
order.php
home.php
about/profiles.php

All of the pages are called by the index.php using GET method like so:

[php]<?php
$page = isset($_GET[‘p’]) ? $_GET[‘p’] : ‘home’;

switch($page) {

/----------------------- PAGES -----------------------------------/

case ‘about’:
$title = ‘about’;
$keyword = ‘some keywords’;
$description = ‘some description’;
break;

case ‘contact’:
$title = ‘contact’;
$keyword = ‘some keywords’;
$description = ‘some description’;
break;

case ‘order’:
$title = ‘order’;
$keyword = ‘some keywords’;
$description = ‘some description’;
break;

case ‘about/profiles’:
$title = ‘order’;
$keyword = ‘some keywords’;
$description = ‘some description’;
break;

default:
$title = ‘home’;
$keyword = ‘some keywords’;
$description = ‘some description’;
break;

}
include(‘include/header.php’);

include(’’.$page.’.php’);

include(‘include/footer.php’);
?>

[/php]

My links in the webpages look like this:

[php]
About
Profiles
Home
Contact
Order
Profiles

[/php]

I have rewritten my URLs with MOD_rewrite in a .htaccess file which you can see below:

Code: [Select] RewriteEngine On Rewritebase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^robots\.txt$ RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]

Everything works fine when I navigate through contact, order and home. But when I select “about” it gives me the following message:

Index of /about
[ICO] Name Last modified Size Description
[DIR] Parent Directory -
[ ] profiles.php 26-Mar-2012 17:15 1.3K
Apache/2.2.20 (Ubuntu) Server at mysite Port 80

I have a few links on the about.php page also that point to http://www.mysite/about/profiles

I hope that makes better sense?


#7

Must be me, but i still i don’t see anything for Book. That’s what you said you tried to select.


#8

Okay, so your .thaccess rewrite has three conditions.
The first says if filename is not a standard file.
The second says if filename is not a standard directory.
The third says nothing. It is an illegal call.

Sorry I did not catch this before. After reviewing your other pages and code, I see that it is just what you asked at first. But, it went right by me. So…

This:
RewriteCond $1 !^robots.txt$
RewriteRule ^([^/.]+)/?$ index.php?page=$1 [L]

Is not valid because it uses the $1 variable before it is set. You can not do that. You would have to change it to just do the condition and alter the rule a little… This is not my area, but, something like this should work for you:
RewriteCond !^([^/.]+/?$^robots.txt$)
RewriteRule (.*) index.php?page=$1 [L]
NOTE: Not sure about that last COND! I do not use rewrite much… But, that is most likely the problem.
Let us know if that solves it.


#9

about is a directory try to disable apache index, ive tried your code out and it works to me.
I think this should do it… i`m not sure, ive not worked much with .htaccess and mod_rewrite


#10

Hi,

I tried that and get the following error:

Forbidden

You don’t have permission to access /about/ on this server.


#11

chmod +x or 0777 the about folder


#12

Still nothing :frowning: Im pulling my hair out here


#13

you can try to set apache the owner of directory about, assuming your apache user is called apache(sometimes is called www-data or httpd, you have to look up which user belongs the www directory)
chown apache direct/path/to/your/directory (ex. /usr/www/about)