Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Htaccess不适用于url php_Php_.htaccess_Friendly Url - Fatal编程技术网

Htaccess不适用于url php

Htaccess不适用于url php,php,.htaccess,friendly-url,Php,.htaccess,Friendly Url,我正在尝试用PHP制作漂亮的url。URL正在工作,但CSS和JS不工作 文件路径为:example.com/store.php?brand=brand\u name 所需url: 代码: RewriteEngine On RewriteRule ^store/(.*)/?$ store.php?brand=$1 [NC,L] # Handle product requests 与.htaccess无关。实际上,由于路径不正确,您的页面并没有得到CSS和JS,这就是问题的原因 您需

我正在尝试用PHP制作漂亮的url。URL正在工作,但CSS和JS不工作

文件路径为:example.com/store.php?brand=brand\u name

所需url

代码:

RewriteEngine On
RewriteRule ^store/(.*)/?$ store.php?brand=$1    [NC,L]    # Handle product requests

与.htaccess无关。实际上,由于路径不正确,您的页面并没有得到CSS和JS,这就是问题的原因

您需要为您的域设置常量变量,如BASE_URL,您将在所有CSS和JS中包括该变量,如下所示:

base_url.php

<?php
define('BASE_URL', 'http://example.com');
?>

index.php:

<?php
    include('base_url.php');
?>
<!DOCTYPE html>
<html>
  <head>
    <!-- // -->
    <link rel="stylesheet" href="<?php echo BASE_URL; ?>/css/styles.css" />
 </head>
 <body>
 <!-- // -->
 </body>
</html>


不客气,老兄。别忘了接受我的回答。快乐编码:)