Solved

Setup file extension change in HTACCESS

Posted on 2014-03-13
7
365 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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 look for a specific file type in a local or remote server directory using PHP.

920 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

16 Experts available now in Live!

Get 1:1 Help Now