datadoit
|
Posted: 08/15/2008, 8:10 PM |
|
This applies only to PHP running on an Apache Web Server.
This tip will allow you to redirect all requests to view .html pages to
the accompanying .php page instead.
Start by creating an .htaccess file in the web folder you want this rule
applied to (if none yet exists). Then, add this rule to the file:
# Redirect viewing of html page to php page.
RedirectMatch 301 (.*)\.html$ $1.php
Tested on a couple of CodeCharge projects and appears to work well.
Note that if you have an .html page created out of CodeCharge (ie: no
accompanying .php file), you will not be able to view it.
|
|
 |
wkempees
Posts: 1679
|
Posted: 08/16/2008, 5:23 AM |
|
If anyone is not able to accomplish this, either because of limited right or capabilities:
In Project Setting->Server/Script->Template Path , add a 'path' like 'template' or 'tpl'.
CCS will then publish all .html in that directory and change all the calls to the templates.
On a more general note, if you want to stop the outer world viewing the content of such directories, just add an empty file 'index.html'
Good tip thanks.
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
jjrjr1
Posts: 942
|
Posted: 08/17/2008, 7:23 AM |
|
Hi
Just thought I would add my 2 cents here.
You could also put into the .htaccess file
DirectoryIndex index.php index.html index.htm etc....
This will change the order in which apache will serve up pages.
In the above example apache will try the index.php file. Then if not found the index.html file and down the list in the order you specify.
This way you do not have to do any mod rewrites.
If you have access to the apache config files you can put this directive into the
httpd.conf file and srm.conf files on your server and the change will affect all domains on your server.
Bye for now.
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
datadoit
|
Posted: 08/17/2008, 9:00 AM |
|
Recognize that this is for attempts to view your .html files directly.
Ex: http://www.yourdomain.com/yourpage.html
We discovered this problem when we found someone inadvertently linked to
us using the html file instead of the php file.
|
|
 |
jjrjr1
Posts: 942
|
Posted: 08/17/2008, 9:32 AM |
|
Hi Data
Your right. The directory Index is just for default access.
I never came across this problem as I always configure my projects like Walter suggested. I keep all html templates in a html directory to keep the root clean.
However, I like your trick and will remember it.
Take Care.
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
datadoit
|
Posted: 08/19/2008, 8:47 AM |
|
Note that this will break the DatePicker, which is all HTML (no PHP
files). Here's an update to the .htaccess file, with a requirement that
the rewrite module is running on Apache.
RewriteEngine ON
# Redirect viewing of html pages to php pages.
# Exclude the DatePicker.html from the rule since there's no
# accompanying php file.
RewriteCond %{THE_REQUEST} !^.*/DatePicker.html
# Redirect all other html requests to the appropriate php file.
RewriteRule ^(.*)\.html$ $1.php
|
|
 |
feha
Posts: 712
|
Posted: 09/02/2008, 6:10 AM |
|
Hi, my 2 cents
You need to add in your .htaccess file this line
DirectoryIndex index.php index.html
This is priority order ..
first will be executed index.php if not found than index.html ...
Hope this helps ...
_________________
Regards
feha
www.vision.to
feedpixel.com |
 |
 |
thomasbjo
Posts: 43
|
Posted: 09/13/2008, 2:20 PM |
|
Quote datadoit:
Note that this will break the DatePicker, which is all HTML (no PHP
files). Here's an update to the .htaccess file, with a requirement that
the rewrite module is running on Apache.
RewriteEngine ON
# Redirect viewing of html pages to php pages.
# Exclude the DatePicker.html from the rule since there's no
# accompanying php file.
RewriteCond %{THE_REQUEST} !^.*/DatePicker.html
# Redirect all other html requests to the appropriate php file.
RewriteRule ^(.*)\.html$ $1.php
It also affects the FCKeditor where i guess it is that much harder to make exeptions in .htaccess.? (When not needed I will use your tip).
The hideing can be done like this to:
<Files index.html>
order allow,deny
deny from all
</Files>
Where you can replace index.html with any file you want to hide.
_________________
"I know a 100 ways on how it does not work"
http://bjoernvold.com |
 |
 |
Zye
Posts: 56
|
Posted: 09/15/2008, 5:53 PM |
|
FCKeditor
RewriteCond %{THE_REQUEST} !^.*/fckeditor.html
Thanks for the tip datadoit
|
 |
 |
feha
Posts: 712
|
Posted: 09/17/2008, 1:56 PM |
|
Uh, sorry i did not read that you want to "hide" .html files
_________________
Regards
feha
www.vision.to
feedpixel.com |
 |
 |