2011-11-28 73 views
0

我目前有动态页面。例如,index.php?p=proposal打开一个页面从/pages/landing.php在我的网站www/researchportal/使用.htaccess动态页面

目前的根,http://localhost/researchportal/proposal的页面似乎由它自己(只是proposal.php,没有CSS的内容)加载,而不是通过索引.php文件。这意味着CSS没有正确加载。

http://localhost/researchportal/index.php?p=proposal 

此链接可以正确载入CSS。

http://localhost/researchportal/proposal 

此链接不包含在index.php文件中定义的标题和CSS。位于我的网站的根www/researchportal/

RewriteEngine On 
RewriteRule ^([A-Za-z0-9-_]+)$ index.php?p=$1 

为什么心不是http://localhost/researchportal/proposal加载正确

我的.htaccess文件?

回答

0

我认为xxx.css的服务器请求重新路由到index.php,你应该为你的css和image目录添加一个exe文件到你的正则表达式模式。允许robots.txt的例外也是有用的。

0

你现在的规则会发送所有的请求到index.php。您需要添加一个条件来阻止对实际存在的文件/目录的请求,例如css被发送到index.php

RewriteEngine On 
#Also recommend that you add a an explicit RewriteBase 
RewriteBase/

#only run this rule if the request is not for an existing file or directory 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([A-Za-z0-9-_]+)$ index.php?p=$1