|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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] |
|
#2
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > System Administration > Apache Development > Rewrite Rule/Cond failing |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|