2012-06-03 27 views
0

我有PHP的作品真棒 但我想它显示变量看起来像迪尔斯htaccess的用不同的名称/变量连击PHP的

如改变:

example.com/?mode=page&page=15example.com/page/15

example.com/?mode=pic&picid=136example.com/pic/136

howe版本我只知道这样做的一种方式,如:

RewriteRule ^(.*)$ index.php?mode=$1&page [R]

但只适用于一种情况,否则404

我尝试使用RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]使整个路径被传递。但是,这种方式似乎并没有在我的页面中传递CSS。

我非常困惑......

这是我的htaccess文件

# Do not remove this line, otherwise mod_rewrite rules will stop working 
RewriteBase/

IndexIgnore * 


RewriteEngine On 


RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l 
RewriteCond %{REQUEST_URI} !^css/styles\.css$ 

RewriteRule ^(.*)$ index.php?url=$1 [L,QSA] 
+0

如果仍令人担忧:是您的基本URI域或本地主机后直接?如果不是,你必须在html中的路径中引用它。 – fourreux

回答

0

问题是你正在重写所有URL以

index.php?url= 

所以你的CSS文件,还可以得到“重定向“到”index.php?url =“例如

index.php?url=css/styles.css 

因此,您需要将“条件”添加到.htaccess中,以便某些文件(或目录)不会“重定向”。你可以在你的“RewriteRule”之前使用“RewriteCond”(条件)来做到这一点。

例如不“重定向” CSS文件“CSS/Styles.css中”你可以做

RewriteCond %{REQUEST_URI} !^css/styles\.css$ 
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA] 
+0

我试图添加该条件,但它不工作:/ – Isaac

+0

如果我去example.com/asd它不会打破CSS。但是,如果我输入example.com/asd/asd或多个变量,那么它会打破CSS – Isaac