dongnaoxia0927 2016-08-05 18:01
浏览 72

使用默认的Wordpress .htaccess设置“找不到”CSS文件

I inherited a Wordpress project.

I added a CSS file to theme (e.g. extra.css).

But if I try to load it in the browser like so:

http://example.com/wp-content/themes/MyTheme/extra.css

I get a 'page not found' error. The file IS on the server in that directory.

If I create a new folder in the theme folder and try the URL, like so:

http://example.com/wp-content/themes/MyTheme/test/test.txt

The text file loads fine. I can't understand why ONLY CSS files won't load from the filesystem. I checked the .htaccess file - and the settings are the WP default.

So how can I get WP to recognize new CSS files in this instance? Or what might be the cause of this issue?

UPDATE: Two factors may be influencing this: (1) this is a virtual server managed by cPanel (ugh), and (2) the Wordpress theme is Avada by Theme Fusion, which seems to add a lot of strange bloat to the site.

.htaccess contents:

# BEGIN custom php.ini PHP54
<IfModule mod_suphp.c>
    suPHP_ConfigPath /home/example/public_html
</IfModule>
# END custom php.ini

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
  • 写回答

1条回答 默认 最新

  • dongpaozhi5734 2016-08-05 18:19
    关注

    You can add this link into your header with proper file location

    <link href="<?php echo get_template_directory_uri(); ?>/css/style.css" rel="stylesheet" type="text/css" />
    

    get_template_directory_uri() will go upto your theme go to header.php add

    <link href="http://example.com/wp-content/themes/MyTheme/extra.css" rel="stylesheet" type="text/css" />
    

    inside title tag so it will be

    <title>
      <link href="http://example.com/wp-content/themes/MyTheme/extra.css" rel="stylesheet" type="text/css" />
    </title>
    
    评论

报告相同问题?

悬赏问题

  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加