2013-11-15 61 views
1

我一直在尋找遍地找到一些代碼來處理我的godaddy URL重寫,但沒有運氣。在godaddy共享服務器上使用.htaccess的友好URL/URL重寫

我想讓我的網站帶有.htaccess等友好的URL。 domain.com/company/buy/items.php?fatherID=23 ==>進入==> domain.com/23我嘗試了幾乎所有的代碼,最好的辦法是刪除.php

示例代碼:在

RewriteEngine敘述在

RewriteBase

選項+的FollowSymLinks -MultiViews

打開了mod_rewrite/

重寫規則^ /([0-9] +)/ $合作mpany/items.php?fatherID = $ 1 [NC,L]

有沒有人有一些簡單的代碼有什麼想法?我在godaddys共享的Linux服務器上。

我試圖修復404錯誤代碼: ErrorDocument 404 /domain.com/home/404error.php 但這也行不通。

有什麼我失蹤?

+0

刪除/可選的前導'/'斜槓。而你沒有RewriteBase的用例。 – mario

回答

1

試試這個,應該是工作

<IfModule mod_rewrite.c> 
Options -MultiViews  
    RewriteEngine on 
    RewriteBase/
    RewriteRule ^([0-9]+)$ company/items.php?fatherID=$1 [L] 
</IfModule> 
+0

我試過了這段代碼,但沒有成功。有什麼我失蹤?最初我沒有一個.htaccess文件。我也嘗試清除我所有的網絡歷史記錄和cookies –

+0

我認爲你沒有啓動帶有Options + FollowSymlinks的.htaccess文件 –

0

Godaddy的是一種特殊情況。它會工作肯定。

DirectoryIndex index.php 
AddDefaultCharset utf-8 

RewriteEngine on 
Options +FollowSymlinks -MultiViews -Indexes 

RewriteBase/
RewriteRule ^/([0-9]+)/?$ company/items.php?fatherID=$1 [NC,L] 
相關問題