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
Php 使用.htaccess和mod_rewrite重写URL会导致服务器错误_Php_.htaccess_Url_Mod Rewrite_Rewrite - Fatal编程技术网

Php 使用.htaccess和mod_rewrite重写URL会导致服务器错误

Php 使用.htaccess和mod_rewrite重写URL会导致服务器错误,php,.htaccess,url,mod-rewrite,rewrite,Php,.htaccess,Url,Mod Rewrite,Rewrite,我正在写一个网站,在主目录中有一个php文件,它将获取查询字符串中的GET变量,并根据查询字符串id打开一个视频。查询字符串是:。我想让那根绳子看起来像。我在安装了mod_rewrite的Apache服务器上使用.htaccess文件,因此我将此作为.htaccess文件: Options +FollowSymLinks Options -MultiViews RewriteEngine On RewriteRule ^playlists/([0-9]+) /playlists.php?id=

我正在写一个网站,在主目录中有一个php文件,它将获取查询字符串中的GET变量,并根据查询字符串id打开一个视频。查询字符串是:。我想让那根绳子看起来像。我在安装了mod_rewrite的Apache服务器上使用.htaccess文件,因此我将此作为.htaccess文件:

Options +FollowSymLinks
Options -MultiViews

RewriteEngine On
RewriteRule ^playlists/([0-9]+) /playlists.php?id=$1 [L]

RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_fileNAME} !-d
RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule (.*) $1.php [L]

当我输入带有查询字符串的URL时,web页面将按其应该的方式加载。但是,当我使用SEO友好的URL时,页面仍然会加载,但没有我使用的任何CSS格式。是我的.htaccess不正确,还是什么?

我建议对CSS和JavaScript使用绝对URL。导致此问题的是相对URL

尝试以下方法:

<link media="screen" href="/style/defaultTheme.css" type="text/css" rel="stylesheet">
<link media="screen" href="/style/tablethemes.css" type="text/css" rel="stylesheet">


查看
错误日志
,了解错误的具体信息。重写规则似乎没问题。错误日志怎么说?是否加载了重写库?可能很简单,因为服务器的配置不允许.htaccess中的重写或php_值指令(太严格的AllowOverride选项)。去掉.htaccess中的php_值选项使mod_重写工作,但是现在,在查询字符串URL上使用重写的URL时,CSS格式将丢失。您可以在html文档中使用绝对URL或
。使用绝对URL或,可以解决我的问题。谢谢