简体   繁体   English

在`css`文件中允许`.php`扩展名

[英]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. 单击此处查看我在使用什么,它保存在style.css.php文件中。

In .htaccess file i have denied PHP extension to be used on website as per below code 在.htaccess文件中,我拒绝按照以下代码在网站上使用PHP扩展名

# 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" /> <link href =“ css / styles.css.php” />

then i am getting error that .php is not permitted. 那么我得到的错误是不允许使用.php So, how can i make sure that .php extension is allowed on links and scripts. 因此,如何确定链接和脚本中允许使用.php扩展名。

RewriteCond %{REQUEST_FILENAME}.php -f 

this hiddes .php ext, try 这个隐藏的.php ext,尝试

RewriteCond %{REQUEST_FILENAME} -f 

or try 或尝试

css/styles.css.php 

without .php ext. 没有.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 但是您应该能够删除“ .css”并仅保留“ .php”并将其作为

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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