2012-01-30 86 views
1

我一直在使用apache成功地在不同的服務器上使用.htaccess,但由於某種原因,我無法得到它在這個新的託管軟件包上工作,因爲我不斷收到「Page not found」屏幕上顯示以下消息:「在此服務器上未找到請求的URL/about-us」。 網址瀏覽器看起來就像這樣:www.mysite.com/about-us.htaccess轉到404 - url重寫

我的代碼如下:

RewriteEngine on 
Options +FollowSymlinks 
DirectoryIndex index.php 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !=/favicon.ico 
RewriteRule ^(.*)$ index.php?mode=$1 [L,QSA] 

任何幫助表示讚賞 感謝

+0

您的新託管服務提供商是否支持mod_rewrite? – 2012-01-30 15:18:49

+0

我在中添加了我的代碼。我將DirectoryIndex index.php更改爲DirectoryIndex index.htm index.php,現在該站點將我帶到index.htm。我想這意味着啓用了mod重寫。 – fred 2012-01-30 15:27:54

+0

答案: 'RewriteRule ^(。*)$ /index.php?mode=$1 [L,QSA]' – fred 2012-01-30 17:21:11

回答

0

你的favicon.ico條件可能打破比賽。爲了否定一個模式,只使用!而不是否定詞典上相等的匹配。

RewriteEngine on 
Options +FollowSymlinks 
DirectoryIndex index.php 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !^favicon\.ico [NC] 
RewriteRule ^(.*)$ index.php?mode=$1 [L,QSA]