2013-07-11 22 views
0

我想管理我的網站我如何在php中使用.htaccess管理網址?

的URL,現在它的顯示我www.computermall.co.in/product_details.php?prdid=34

,但我想www.computermall.co.in/product_details/34

我該怎麼辦?

我已經嘗試了本

Options +FollowSymlinks -MultiViews 
RewriteEngine On 
RewriteBase /computermall 

# Get the URI-path directly from THE_REQUEST variable 
RewriteCond %{THE_REQUEST} ^(GET|HEAD)\s/(.*)\.php [NC] 
# Strip the extension and redirect permanently 
RewriteRule .* /%2 [R=301,L,NC] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !\.php [NC] 
# Map internally to the original resource 
RewriteRule ^(.*)$ $1.php [L,QSA] 
+0

我也想知道答案.... – Gautam3164

+0

YAA人我已經嘗試了很多,但沒有結果 –

回答

0

試試這個:

RewriteEngine On 
RewriteRule ^product_details/prdid/([^/]*)$ /product_details?prdid=$1 [L] 

編輯:刪除斜線

+0

它不工作......可我知道我應該在哪裏添加這個代碼?我應該再次添加RewriteEngine嗎? –

+0

將其添加到名爲.htaccess的文件中,並將其放入Web根目錄中。 – Ruben

+0

對我來說同樣的條件也http://stackoverflow.com/questions/17585088/rewrite-condition-is-not-working – Gautam3164

0

首先你RewriteBase /computermall是混亂的,但我有假設那是因爲你的域位於另一個活動域/ http服務器路徑的子目錄中。

這是你的htaccess

RewriteBase/
RewriteRule ^computermall/product_details/([^/]*)/([^/]*$ /computermall/product_details?prdid=$2 [R=301,L] 
+0

其實現在我正在本地主機上工作...這是我在本地主機上的URL .... http:// localhost/computermall/product_details?prdid = 28 –

+0

同樣的條件也爲我http://stackoverflow.com/questions/17585088/rewrite-condition-is-not-working – Gautam3164

+0

檢查我更新的答案 – DevZer0