Wordpress:url资源返回404

时间:2014-03-13 14:21:18

标签: wordpress .htaccess url virtualhost permalinks

我在wordpress中遇到资源网址问题。

在索引页面中,我的css资源,js和图像被正确调用:

  

可湿性粉剂内容/主题/聚焦模板/ JS / LIB / jquery.min.js

但是在帖子详情页面上,帖子的名称会添加到网址:

  

myDomain.com/projet-2012/wp-content/themes/focus-template/js/lib/jquery.mixitup.min.js   404(未找到)

我认为我的虚拟主机配置错误,但我无法找到问题所在..

<VirtualHost *:80>
ServerName local.afric-edu.com
DocumentRoot /var/www/afric-edu/
ErrorLog /var/log/apache2/errors.log
 <Directory "/var/www/afric-edu">
    AddDefaultCharset UTF-8

DirectoryIndex index.php index.html
RewriteEngine On
RewriteBase /
AddType image/gif .gif
AddType image/ief .ief
AddType image/jpeg .jpeg .jpg .jpe
AddType image/png .png

  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !^.*\.(jpe?g|png|gif|css|js)$ [NC]
  RewriteRule . /index.php [L]
  Order allow,deny
  Allow from all
  AllowOverride All
  </Directory>
</VirtualHost>

编辑:

以这种方式调用资源:

<head>
    <meta charset="utf-8">
    <meta name="robots" content="index, nofollow">
    <meta name="description" content="Your website description here">
    <meta name="keywords" content="your, website, keywords, here">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="viewport" content="width=device-width">

    <link rel="shortcut icon" href="../images/favicon/favicon.ico">

    <title><?php wp_title( '|', true, 'right' ); ?></title>
    <link rel="profile" href="http://gmpg.org/xfn/11">
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
    <script type="text/javascript" src="wp-content/themes/focus-template/js/lib/jquery.min.js"></script>
    <script type="text/javascript" src="wp-content/themes/focus-template/js/lib/modernizr.js"></script>
    <script type="text/javascript" src="wp-content/themes/focus-template/js/lib/pace.js"></script>
    <script type="text/javascript" src="wp-content/themes/focus-template/js/lib/classie.js"></script>
    <script type="text/javascript" src="wp-content/themes/focus-template/js/lib/jquery.fittext.js"></script>
    <script type="text/javascript" src="wp-content/themes/focus-template/js/lib/jquery.magnific-popup.min.js"></script>
    <script type="text/javascript" src="wp-content/themes/focus-template/js/lib/jquery.mixitup.min.js"></script>
    <script type="text/javascript" src="wp-content/themes/focus-template/js/lib/jquery.sudoslider.min.js"></script>
    <script type="text/javascript" src="wp-content/themes/focus-template/js/lib/jquery.superslides.min.js"></script>
    <script type="text/javascript" src="wp-content/themes/focus-template/js/lib/smoothscroll.js"></script>



    <link rel="stylesheet" href="wp-content/themes/focus-template/css/lib/font-awesome.min.css">
    <link rel="stylesheet" href="wp-content/themes/focus-template/css/lib/magnific-popup.css">
    <link rel="stylesheet" href="wp-content/themes/focus-template/css/lib/lite.css">
    <link rel="stylesheet" href="wp-content/themes/focus-template/css/style.css">
    <link rel="stylesheet" href="wp-content/themes/focus-template/css/colors/yellow.css">
    <link rel="stylesheet" href="wp-content/themes/focus-template/genericons/genericons.css">



    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <?php wp_head(); ?>
</head>

你知道很热吗?

感谢您的帮助:)

1 个答案:

答案 0 :(得分:0)

你不应该链接到这样的资源而是使用类似的东西:

<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/lib/jquery.min.js"></script>

您可以在代码here

处查看该功能