简体   繁体   中英

Allow `.php` extension in `css` files

I am doing minification and combining of files on the fly with the help of some tutorials.

Click Here to see what i am using and this is saved in style.css.php file.

In .htaccess file i have denied PHP extension to be used on website as per below code

# remove .php from URL
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L] 

# restrict .php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /[^\ ]+\.php($|\ )
RewriteRule \.php$ / [F,L]

and it is working all fine. But when i am tring to use

<link href="css/styles.css.php" />

then i am getting error that .php is not permitted. So, how can i make sure that .php extension is allowed on links and scripts.

RewriteCond %{REQUEST_FILENAME}.php -f 

this hiddes .php ext, try

RewriteCond %{REQUEST_FILENAME} -f 

or try

css/styles.css.php 

without .php ext.

I'm not seeing what you're working on based on the link you provided, so forgive me if this isn't what you're looking for or I've misunderstood. But you should be able to remove the ".css" and simply leave the ".php" and have it as

<link ...  href='css/style.php'/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM