Solved

Setup file extension change in HTACCESS

Posted on 2014-03-13
7
364 Views
Last Modified: 2014-03-13
I have a folder on my website /scripts/... and I want to change the extension of style.php to style.css...

What script do would you use in the htaccess? and is the htaccess file be in the script folder or the root?

Many thanks in advance
0
Comment
Question by:mcluff
  • 4
  • 3
7 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39926045
Probably .htaccess is in the root directory.  But this is an unusual request.  PHP scripts are usually sent through the PHP parser and CSS scripts are usually not parsed.  These are normally very different file types, but in advanced applications there could be a lot of utility in parsing a CSS file.

Can you tell us a little more about the background concepts?  For example, why not just rename the files and use the conventional names?
0
 

Author Comment

by:mcluff
ID: 39926094
Hi Ray,

style.php has my dynamic css from a database in... but I want my head to display

<link type="text/css" rel="stylesheet" href="/scripts/style.css">
not
<link type="text/css" rel="stylesheet" href="/scripts/style.php">
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39926156
Sure, that makes sense to me.  BTW, I do the same thing with HTML files, so I can let the HTML coders do whatever they want and I can still use PHP functionality.  Here is the line I put in .htaccess, in my web root directory:

AddType application/x-httpd-php5 .html .htm .php

You could probably use the same sort of thing.  You would want to add .css to the list of file suffixes
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:mcluff
ID: 39926177
Many Thanks Ray...

Just to confirm would this do css...?

AddType application/x-httpd-php5 .css .php
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39926227
Yes, that looks right to me.  I rely on my hosting company to tell me the contents of the "application/x-httpd-XXX" part.
0
 

Author Closing Comment

by:mcluff
ID: 39926240
Great help!
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 39926255
Thanks for the points and thanks for using EE, ~Ray
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now