2013-10-01 130 views
2

我在WordPress的請幫助重寫URL頁面的wordpress

www.xxxxx.com/asin/ 

創建了一個網頁和我進行了一個名爲模板asin.php

網址爲

www.xxxxx.com/asin/?q=B0081HBX2I

www.xxxxx.com/asin/q/B0081HBX2I

已經嘗試過的htaccess

RewriteBase /asin/ 
RewirteRule ^asin/q/([0-9]+)$ ?q=$1 [L] 

任何幫助嗎?謝謝

回答

0

請試試這個:

RewriteRule ^asin/([a-zA-Z0-9_-]+)$ asin.php?q=$1 
+0

感謝您的幫助 我已經試過了,但去404頁找不到 –

0
RewriteBase /asin/ 
RewirteRule ^asin/q/([0-9]+)$ ?q=$1 [L] 

你拼寫錯誤的重寫規則在第二行。此外,在您的正則表達式,你只檢查號碼,請嘗試:

RewriteBase /asin/ 
RewriteRule ^asin/q/([0-9a-zA-Z]+)$ ?q=$1 [L] 
+0

感謝您的幫助 我已經試過了,但去404沒有找到頁面 –

+0

當你嘗試正確的時候,你確實留下了你的'RewriteBase/asin /'行嗎?我已經更新了我的回答 – Jonathon

0

如果您之後/asin/一部分從開始使用RewriteBase那麼你RewriteRule開始匹配URL。你也看到在你的URL中使用alphanum,但你的正則表達式只使用[0-9]

這種替換代碼:

RewriteEngine On 
RewriteBase /asin/ 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^q/([a-z0-9]+)/?$ ?q=$1 [L,NC,QSA] 
+0

感謝您的幫助 我試過了,但轉到404頁未找到 –