...

View Full Version : Adding PHP page?



eperez
05-22-2011, 03:45 AM
A friend made a site for me at http://avertsoftware.com.

I'm not a web developer, so I'm having a hard time updating it, not to mention it was compromised yesterday. But thankfully, I've been able to remedy that issue.

Now, I'm trying to add a new page. But, it's not working.

The current links through out the site look like this:


<li><a href="info/history">History</span></a></li>

Within that list, a page called "history.php" is navigated to under the "info" folder when that link is clicked.

So, I thought to just copy a page, rename it and make a similar anchor:


<li><a href="info/gallery">Gallery</a></li>

But when I do, I get a 404 message.

Does anyone know what I need to do to get this working?

Thanks

Fumigator
05-22-2011, 04:30 AM
Take a look at your .htaccess file. That's probably where the nice URL is being interpreted. I would think you could just add a new file (like you added gallery) and it would work but it really depends on what's going in with your Apache Redirect commands.

eperez
05-22-2011, 05:23 AM
Take a look at your .htaccess file. That's probably where the nice URL is being interpreted. I would think you could just add a new file (like you added gallery) and it would work but it really depends on what's going in with your Apache Redirect commands.

I looked through the entire directory structure of my website and found 2 .htaccess files, but neither had any information about this.

Do you know how I can check the other thing you mentioned?

djh101
05-22-2011, 11:24 AM
It looks to me more like a navigation to a containing folder than a URL rewrite. info/history/history.php and info/history.php both give 404 errors while info/history/index.php does not (which is where the page, without any URL rewriting, would be navigated to by an extension-less URL).

eperez
05-22-2011, 05:57 PM
It looks to me more like a navigation to a containing folder than a URL rewrite. info/history/history.php and info/history.php both give 404 errors while info/history/index.php does not (which is where the page, without any URL rewriting, would be navigated to by an extension-less URL).

Hm... I'm not really sure how to use this information.

I went looking for 'index.php' files, to see if they would help me identify what's going on. But each file only contains the following:


<html>
<head>
<title>403 Forbidden</title>
</head>
<body>

<p>Directory access is forbidden.</p>

</body>
</html>

Which is odd to me. That particular index.php files is in my "view" folder, where the rest of pages are. So I navigated to http://avertsoftware.com/index.php and it brought up my home page. It's clear my understanding of web technologies is severely lacking, because I would have thought I'd see the 403 page.

So I started looking through more files and pages to see if there was anything that seemed like it might help. It turns out that the site built on a PHP framework called codeignitor. I'm not sure if that helps, but hopefully it will help you all understand how everything is being used.

When looking through the directories, I came across two files of interest, "config.php" and "routes.php." Earlier I mentioned that my site was comprised, so when I looked through the "config.php" page, I saw a reference to the spam site:


/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
*/
$config['base_url'] = "http://www.http://secitysupply.com/";

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = "";

I didn't know if that was actually causing any problems because the site is mostly running OK. But I changed it back to my site anyway.

In the routes.php file I saw this:


<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| URI ROUTING
| -------------------------------------------------------------------------
| This file lets you re-map URI requests to specific controller functions.
|
| Typically there is a one-to-one relationship between a URL string
| and its corresponding controller class/method. The segments in a
| URL normally follow this pattern:
|
| example.com/class/method/id/
|
| In some instances, however, you may want to remap this relationship
| so that a different class/function is called than the one
| corresponding to the URL.
|
| Please see the user guide for complete details:
|
| http://codeigniter.com/user_guide/general/routing.html
|

That sounds exactly what I'm aiming for. But... I looked through the file and there's really not much else there. I expected to see a list of pages and their routes, but I got nada. I've attached 'routes.php' as a text file so you all can take a look at it, if you like.

tracknut
05-22-2011, 08:14 PM
Hm... I'm not really sure how to use this information.


I think djh's point was that you have a file at http://avertsoftware.com/info/history/index.php which is displayed with the link: http://avertsoftware.com/info/history. Have you made a folder inside info called "gallery" and put your gallery code in that folder as index.php?

Seems like that would work, with no .htaccess or other stuff.

Dave

eperez
05-22-2011, 09:27 PM
I think djh's point was that you have a file at http://avertsoftware.com/info/history/index.php which is displayed with the link: http://avertsoftware.com/info/history. Have you made a folder inside info called "gallery" and put your gallery code in that folder as index.php?

Seems like that would work, with no .htaccess or other stuff.

Dave

Hm... I can try that, but I'm not sure it will work. Looking through the directory structure, there is no "history" folder and I can't find "index.php" that has any actual code in it.

This is how the directories are setup:
http://imageshack.us/m/708/454/unledrw.png

You can see the "info" folder up top and the pages below. There is no history subdirectory and no index.php files here. This is what's confusing me. I tried what he said and navigated to the /info/history/index.php file and it did indeed work, but the files on my server aren't matching up with that. Whenever I need to make an edit, I just download the appropriate page, make the edit and upload it again. If I need to make a new link to a page, I just create an anchor and call the name of the page without ".php", though it's not working for my "home" page at the moment.

This means that some other code is working behind the scenes, but I have no idea where.

djh101
05-22-2011, 09:36 PM
Since you are using a framework, you could try going to CodeIgniter's site and looking through their user guide and forums. Without looking through all your files, it's going to be hard to help you, myself (since I don't know how CodeIgniter handles URIs).

eperez
05-23-2011, 12:23 AM
Thanks everyone for the help.

I took djh101's advice and visited CodeIgniter's forums and through some guidance, I was able to figure it out.

If you're interested, you can view the thread here (http://codeigniter.com/forums/viewthread/189726/).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum