Forum Moderators: phranque
Here is the .htaccess code:
RewriteEngine on
RewriteBase /
RewriteRule ^index\.html$ index.php
[T=application/x-httpd-php]
...the code returns an error.
Somewhere I recall reading that there was a command that preceded RewriteEngine. Although not certain, I vaguely remember something like Directory.
Any suggestions as to how to fix the non-functioning code or how to find the source of the problem is greatly appreciated.
The mod_rewrite is definitely loaded in the website's Apache.
What I'm trying to accomplish is rather simple--so one would think.
Currently the files appear as:
[mysite.com...]
The goal is to have it rewrite it as:
[mysite.com...]
Condition:
I'd prefer to avoid rewriting the file extention stored on the server from .php to .html. The reason is that it is possible to view an html file under some conditions, which is not true with php files.
Is it possible to display files with php extensions as html files?
Thanks for the feedback.
The .htaccess file now reads:
RewriteEngine on
RewriteBase /
RewriteRule ^index\.html$ /index\.php
[T=application/x-httpd-php]
I'm still getting an Internal Server Error. The Apache server has the mod_rewrite module loaded. When the final line "[T= applic...] is deleted the error goes away, but the php extension shows. Also, the "RewriteBase /" has been remarked out, but the Internal Server Error still appears.
Is there any sort of simple test to help narrow down what the source of the error code could be?
Some time ago I used .htaccess and vaguely recall using 'DirectoryIndex index' in conjunction with (I believe) AddType. Not sure if the DirectoryIndex would make any difference, but did test it with the current code--of course the result was the same.
Just to be clear. The index.php file is written as such. Some tutorials mention rewriting files, i.e. index.php as index.html.
[edited by: Storyman at 6:50 pm (utc) on Oct. 9, 2004]
RewriteEngine on
RewriteBase /
RewriteRule ^index\.html$ /index\.php
...no internal server error is created.
The url continues to show the php extension. For whatever reason it is not rewriting the extension and I'm not sure where to go from here.
As mentioned earlier the goal is to accomplish the rewrite without changing the actual name of the file on the server. The file stored on the server should be index.php and the url address should show the file as index.html
Assuming that you posted the code as it actually appears in your .htaccess file, the problem is that the flags -- the text enclosed by brackets -- must appear on the same line as the RewriteRule.
Literals in regular-expressions patterns must be escaped. There is no need to escape them in the substitution string.
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^index\.html$ index.php [T=application/x-httpd-php,L]
If the above does not work, then it is possible that your server is misconfigured; Try a simpler rewrite and examine your server error log file.
Jim
Mission accomplished!
Thank you for your help. Your last posting had the operative word 'type'. This is one of those 'duh' moments. When index.html is typed the page did appear.
What I was doing was clicking the "HOME" link, which of course was to index.php. After changing the navigation bar to reflect *.html and adding the pages to the RewriteRule all of the pages successfully appear as html pages.
Thanks again.