dqd82461 2013-05-14 06:58 采纳率: 0%
浏览 53
已采纳

css和图像冲突。 htaccess rewriterule [关闭]

I saw many similar problems to what I am experiencing but I already followed every solutions I get from it and it seems that I can't make it run without conflicts.

HTML CSS calls:

<head>
<base href="http://localhost/smartwavedev.sw_apiwebtool/" />
<link rel="stylesheet" href="assets/css/main.css" type="text/css">
<link rel="stylesheet" href="assets/css/login.css" type="text/css">
<link rel="stylesheet" href="assets/css/dashboard.css" type="text/css">
<link rel="stylesheet" href="assets/css/bootstrap/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="assets/css/docs.css" type="text/css">
</head>

.htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)$ $1.php
RewriteRule ^([^/]+)/([^/]+)$ $1.php?page=$2
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ $1.php?page=$2&nav=$3

Thanks for the help!

  • 写回答

1条回答 默认 最新

  • doudou20080720 2013-05-14 07:07
    关注

    First of all this condition is malformed:

    RewriteCond %{REQUEST_FILENAME}\.php -f
    

    It should just be:

    RewriteCond %{REQUEST_FILENAME} !-f
    

    Now it will trigger on all files. Next up, a RewriteCond will only match for the first RewriteRule following it. So the third rule with the 3 elements is still matching (and thus blocking) your CSS files. You either need to repeat the RewriteCond lines for all rules, or implement a better solution. For your specific case, I'd really recommend dropping the entire concept of rewriting and replace it with:

     FallbackResource index.php
    

    And then parse $_SERVER['REQUEST_URI'] in the index.php file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?