2012-07-26 55 views
0

我使用.htaccess为了清理我的链接。 的链接如下所示:htaccess否认我的页面风格

http://www.mydomain.com/home/param2/param3 

我使用爆炸功能让我的参数:

$url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 
$aPages = explode("/", $url); 

if($num >= 0){ 
    return $aPages[$num]; 
} 
else{ 
    return $url; 
} 

我htaccess文件

RewriteEngine On 
RewriteCond %{REQUEST_URI} !=/index.php 
RewriteRule .* /index.php 

如果我的第一个参数( '家')是为空,它将重定向到“找不到页面”的页面。 这一切都很好,但当我打电话给我的样式表('/css/style.css'),网站做同样的事情,不会加载我的样式表。我该如何解决?

+0

你为'index.php' – 2012-07-26 18:34:17

+1

为什么人们标记HTML和CSS的PHP问题 – 2012-07-26 18:34:55

回答

1

试试这个吗?

Options +FollowSymLinks 
IndexIgnore */* 
# Turn on the RewriteEngine 
RewriteEngine On 
# Rules 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . index.php 
+0

谢谢!这工作得很好! – 2012-07-26 20:55:20

1

尝试

RewriteEngine on 
RewriteCond $1 !^(index\.php|images|robots\.txt) 
RewriteRule ^(.*)$ /index.php/$1 [L] 
+0

这不是工作重定向一切。感谢您的努力! – 2012-07-26 18:38:45

+0

@RickSlinkman我没有丰富的.htaccess经验,但这是我能做的最好的。另外,这不是一个PHP的问题。 – Matt 2012-07-26 18:39:49