Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old March 5th, 2001, 03:56 PM
robinsn robinsn is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 12 robinsn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I am trying to create a simple rewrite where, if someone asks for an html file, rewrite looks to see if there is a php file with the same name, and if so it runs that file. If not, it runs the HTML file. Seems fairly simple. There's even a script at http://httpd.apache.org/docs/misc/rewriteguide.html which lays this exact scenario out and the code.

However, I have worked with this for way too long and I cannot get it to work. Here's the code that page lists:

RewriteEngine on
RewriteBase /working/
RewriteRule ^(.*)\.html$ $1 [C,E=WasHTML:yes]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [S=1]
RewriteCond %{ENV:WasHTML} ^yes$
RewriteRule ^(.*)$ $1.html

I only changed the phtml in the original code to php. I've tried several RewriteBase's including deleting it altogether as well as other variations of the other lines.

I get 400 errors when I try to run an html file. Looking at rewrite_log, I see that it is appending the uri to itself several times and coming up with an invalid url. Here's what the log says on the line which is trying to match the php file:

...(4) RewriteCond: input='c:/apache/htdocs/sizeups/working/c:/apache/htdocs/sizeups/working/test2.php' pattern='-f' => not-matched

As you can see, the path is there twice. I can't figure out where the code is doing that. Can anyone help me???

I am runing this on Win98 apache which is my development machine soon to be uploaded to a freebsd machine (once it's working).

To run a PHP file if the html file requested does not exist was easy and I may end up using this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z0-9]+).html$ http://www.sizeups.com/working/$1.php

I know I'd have to delete the html files as we converted them to php, but does anyone see any other problems with this code?

[Edited by robinsn on 03-05-2001 at 02:59 PM]

Reply With Quote
  #2  
Old March 7th, 2001, 02:18 PM
robinsn robinsn is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 12 robinsn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I finally found the cause of the double path to the file!

The line:

Options FollowSymLinks

is required in an .htaccess file in order for the path not to duplicate. Perhaps this info will help someone else who runs across the same problem.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > Rewrite Rule/Cond failing


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway