Reply
links work on live site... not on local machine
Old 04-10-2008, 10:41 AM links work on live site... not on local machine
Average Talker

Posts: 15
Name: Luke
I am moving a website (that I did not code) from one host to another. Before taking it off of one host and moving it, I am making sure I can make it operate on my local machine. When the index.php page is loaded, an array (which pulls from a mysql database) is created that keeps track of each page on the site. The index page itself pulls from this DB to get content, so I know that part works, but the index page is the only page that will load.

The problem is that I do not understand how the page operates when navigating off of the main page:

the site is http://www.midbrook.com

Hovering over links you see urls such as http://www.midbrook.com/equipment or http://www.midbrook.com/about etc. I'm sure the information is in the aforementioned database because there are no corresponding php files (about.php equipment.php). Clicking on these links works on the currently live site, but when I run them from my local machine i get 404 errors.

What am I missing (must be something server side?) to make these urls look in the right place for the page content.

Thanks in advance!

Last edited by lrobinson : 04-10-2008 at 10:42 AM. Reason: bad links
lrobinson is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 04-10-2008, 10:46 AM Re: links work on live site... not on local machine
dansgalaxy's Avatar
Eat, Sleep, Code

Posts: 6,166
Name: Dan
Location: Swindon
Simply Answer: YES.


Its probably that you dont have apache installed on your local machine or that you dont have it in ther root web directory.

The requires mod_rewrite which uses apache...

Not sure what else i can say
__________________
Personal UK Webhosting
Get 25% of ANY shared package for life ~ Promo: webmaster-talk (only for members!)
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 04-10-2008, 10:58 AM Re: links work on live site... not on local machine
Average Talker

Posts: 15
Name: Luke
I do have apache installed on my local machine (it uses apache to load the main page). I am using xampp. I do not know anything about mod_rewrite (i will look into it), but if that is something not included (or that will need configuring) with xampp then I would appreciate any help, insight, references, etc.

Thanks
lrobinson is offline
Reply With Quote
View Public Profile
 
Old 04-10-2008, 11:16 AM Re: links work on live site... not on local machine
dansgalaxy's Avatar
Eat, Sleep, Code

Posts: 6,166
Name: Dan
Location: Swindon
Okay, then i belive it might be the OS, i *think* windows has issues (or just completely ignores) .htaccess files..
__________________
Personal UK Webhosting
Get 25% of ANY shared package for life ~ Promo: webmaster-talk (only for members!)
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 04-10-2008, 11:29 AM Re: links work on live site... not on local machine
rogem002's Avatar
Webmaster Talker

Posts: 607
Name: Mike
Location: United Kingdom
Oh I use XAMPP. It's most likely the configuration of your server compared with XAMPP.

If it is mod_rewrite, it's disabled by deafult (it should not be assumed it's there on all servers, so on a development one it should be disabled). To enable to change the following file:
xampp_Directory\apache\conf\httpd.conf

Change:
#LoadModule rewrite_module modules/mod_rewrite.so
for
LoadModule rewrite_module modules/mod_rewrite.so

It's on line 118, if your still being bummed by XAMPP check you server php_info() and compare with XAMPP.

Dan's it's most likely not to do with OS, as XAMPP's Apache notices the .htaccess file and process it fine on my windows.
__________________
Website Services
PHP Code:
if(Added_Talkupation($post) == TRUE){iHug($you);} 

Last edited by rogem002 : 04-10-2008 at 11:31 AM.
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 04-10-2008, 11:45 AM Re: links work on live site... not on local machine
Average Talker

Posts: 15
Name: Luke
Dan and rogem, You may both be right...

I did enable mod_rewrite in the httpd.conf per your suggestion, but http://localhost still will not load the index.php page with .htaccess in the directory. While debugging, if i put the .htaccess folder into the directory after only the 1st line of code has executed, the index page will load in full. Any link I click on afterwards will prompt me to download a file with the url for that link (i.e. http://localhost/equipment prompts to download a file 'equipment').

I will keep looking for .htaccess incompatibilities with windows in the meantime and post anything I find. Thank you for the good advice, you have been very helpful so far!
lrobinson is offline
Reply With Quote
View Public Profile
 
Old 04-10-2008, 11:46 AM Re: links work on live site... not on local machine
dansgalaxy's Avatar
Eat, Sleep, Code

Posts: 6,166
Name: Dan
Location: Swindon
okay i just thought i saw somewhere it had some problem or other with soemthing

Anyways, i think Mike cracked it

I have yet to really get stuck into config files as havent had the need!

- cant wait till im a super geek i get a license and everything then i will know everything.. and be called Dr Dan Rodgers Computer genius and multi-billionaire owner of ***** (company name still under development)
__________________
Personal UK Webhosting
Get 25% of ANY shared package for life ~ Promo: webmaster-talk (only for members!)
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 04-10-2008, 12:04 PM Re: links work on live site... not on local machine
King Spam Talker

Posts: 1,083
Quote:
Originally Posted by dansgalaxy View Post
Okay, then i belive it might be the OS, i *think* windows has issues (or just completely ignores) .htaccess files..

You are not using windows when you are serving pages with Apache.

Mod rewrite works fine under XP and Xampp after you enable it.

For the OP if you have viewed the .htaccess file using notepad more than likely it has been saved as .htaccess.txt which makes it useless. Use a different editor and save it with no file extension. Notepad2 is free and works fine.
colbyt is offline
Reply With Quote
View Public Profile
 
Old 04-10-2008, 12:14 PM Re: links work on live site... not on local machine
Average Talker

Posts: 15
Name: Luke
I wish the problem was as easy as you suggest, colbyt, but it is definitely an htaccess file. After looking closer at the contents of the .htaccess file, I've noticed it mentions mod_rewrite.c and in the httpd.conf there is a .so extension. I dont know if that is right, wrong, or how it should look at all. Maybe it will be obvious to someone what the problem is... here is the segment from the .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Thanks again!
lrobinson is offline
Reply With Quote
View Public Profile
 
Old 04-10-2008, 12:21 PM Re: links work on live site... not on local machine
rogem002's Avatar
Webmaster Talker

Posts: 607
Name: Mike
Location: United Kingdom
It could be that the mod_rewrite file on your host has a different file name to that of your server. Try changing that line to something like:
Code:
<IfModule mod_rewrite.so>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
__________________
Website Services
PHP Code:
if(Added_Talkupation($post) == TRUE){iHug($you);} 
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 04-10-2008, 12:28 PM Re: links work on live site... not on local machine
Average Talker

Posts: 15
Name: Luke
Quote:
Try changing that line to something like:

Code:
<IfModule mod_rewrite.so>RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</IfModule>
Didnt work but thanks
lrobinson is offline
Reply With Quote
View Public Profile
 
Old 04-10-2008, 01:07 PM Re: links work on live site... not on local machine
dansgalaxy's Avatar
Eat, Sleep, Code

Posts: 6,166
Name: Dan
Location: Swindon
try removing the ifmodule tags

Dan
__________________
Personal UK Webhosting
Get 25% of ANY shared package for life ~ Promo: webmaster-talk (only for members!)
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 04-10-2008, 01:31 PM Re: links work on live site... not on local machine
Average Talker

Posts: 15
Name: Luke
Quote:
try removing the ifmodule tags
No luck
__________________
Luke Robinson
http://www.midbrook.com
lrobinson is offline
Reply With Quote
View Public Profile
 
Old 04-10-2008, 02:15 PM Re: links work on live site... not on local machine
Average Talker

Posts: 15
Name: Luke
Ok, I determined that the line of .htaccess causing the prompt for file download is:

AddHandler application/x-httpd-php5 .php

If i take that line out, then the site loads and the links work!! Can anyone tell me why that line might have caused the prompt for download or what that line of code is intended to do.

Also, more generally, when I move this site to a new host might I have to replace this line? What would differentiate the need for it... the version of PHP installed on the server?

Thank you to everone who helped me!
__________________
Luke Robinson
http://www.midbrook.com
lrobinson is offline
Reply With Quote
View Public Profile
 
Old 04-10-2008, 02:28 PM Re: links work on live site... not on local machine
rogem002's Avatar
Webmaster Talker

Posts: 607
Name: Mike
Location: United Kingdom
The new host may not have php5 installed and still be on php4, some host's don't have the gonads to upgrade to PHP5 (which is stable).
__________________
Website Services
PHP Code:
if(Added_Talkupation($post) == TRUE){iHug($you);} 
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 04-10-2008, 02:36 PM Re: links work on live site... not on local machine
Average Talker

Posts: 15
Name: Luke
I will find out what version of php is on the host before moving it there. The site seems to be working locally except for the contact page. I am getting an error for an undefined function: getmxrr() which apparently is built in to php. Is this a module i need to uncomment in httpd.conf also?

Thanks!
__________________
Luke Robinson
http://www.midbrook.com
lrobinson is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to links work on live site... not on local machine
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 4.25014 seconds with 12 queries