2013-09-25 100 views
1

即時通訊重寫規則有一些困難。我.htaccess看起來是這樣的:htaccess重寫規則不適用於某些頁面

<IfModule mod_rewrite.c> 
RewriteEngine On 

RewriteRule admin/add-category$ adm_add_category.php [NC] 
RewriteRule admin/categories-management$ adm_categories_management.php [NC] 
RewriteRule admin/user-settings/(.*)$ adm_user_settings.php?update=$1 [NC] 
RewriteRule admin/website-settings/(.*)$ adm_website_settings.php?update=$1 [NC] 
RewriteRule admin/users-management$ adm_users_management.php [NC] 
RewriteRule admin/websites-management$ adm_websites_management.php [NC] 

RewriteRule settings/profile$ changesettings.php [NC] 
RewriteRule settings/websites$ my_websites.php [NC] 
RewriteRule settings/password$ changepassword.php [NC] 
RewriteRule settings/logout$ logout.php [NC] 

RewriteRule pages/index$ index.php [NC] 
RewriteRule pages/access$ access.php [NC] 
RewriteRule pages/submit-url$ submit_url.php [NC] 
RewriteRule pages/online-users$ online_users.php [NC] 
RewriteRule pages/register$ register.php [NC] 
RewriteRule pages/websites$ websites_list.php [NC] 
RewriteRule pages/websites/(.*)$ websites_list.php?page=$1 [NC] 
RewriteRule pages/contact$ contact.php [NC] 

RewriteRule search/(.*)$ search.php?term=$1 [NC] 
RewriteRule category/(.*)$ category.php?name=$1 [NC]  

RewriteRule profile/(.*)$ profile.php?username=$1 [NC] 
RewriteRule website/(.*)$ website.php?name=$1 [NC] 


所有除下列的重寫的工作:

RewriteRule search/(.*)$ search.php?term=$1 [NC] 
RewriteRule category/(.*)$ category.php?name=$1 [NC]  

RewriteRule profile/(.*)$ profile.php?username=$1 [NC] 
RewriteRule website/(.*)$ website.php?name=$1 [NC] 

當試圖加載特定的配置文件,如/ profile文件/ exampleguy,會顯示404錯誤。有誰知道這會導致什麼?

404的樣子:

The requested URL /profile/exampleguy was not found on this server. 

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. 

讓我知道如果你需要更多的信息,我真的很感激的幫助!

回答

4

添加L標誌每條規則,使其[NC,L]然後添加:

Options +FollowSymLinks -MultiViews 

.htaccess

頂部
+0

這解決了它。謝謝! – ThatGuy343

+0

不客氣,很高興它爲你解決。只要SO允許,請考慮將其標記爲「已接受」。 – anubhava

+0

+1,如果你添加小解釋也會很好 –

1

您是否嘗試過在某些重寫條件下重定向到默認頁面?

RewriteCond %{REQUEST_FILENAME} !-d //Rewrites if the directory doesn't exist 
RewriteCond %{REQUEST_FILENAME} !-f //Rewrites if the file doesn't exist 

RewriteRule ^(.*)$ index.php?$1 [L,QSA] // Change this to suit your needs 

另外,我猜測你所得到的404,因爲像/型材/實際存在,但不是「exampleguy」,如果沒有在這些目錄中的另一個的.htaccess搭上問題,則服務器將嘗試找到該網頁(和失敗....)