2014-02-27 55 views
0

我需要重寫網址,其中網址爲rewritting:網址使用的.htaccess爲不受歡迎的詞彙去除

http://www.domainname.co.uk/blog/gallery/gallery2 --> URL1 

需要加以

http://www.domainname.co.uk/gallery/gallery2 ---> URL2 

其中http://www.domainname.co.uk/blog是與WordPress安裝目錄。 現在,當我輸入URL2時,它應該顯示URL1的內容。 這可能嗎?我只需要刪除單詞博客。

任何幫助表示讚賞。

謝謝。

-----------我的.htaccess ---------

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 

RewriteRule ^(gallery/.+)$ /blog/$1 [L,NC] 
</IfModule> 
+0

考慮使用重定向插件:http://wordpress.org/plugins/redirection/ –

回答

1

編輯
你可以使用重寫規則,如果如下您在htaccess所在的根文件夾中使用index.php。

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/
    RewriteRule ^index\.php$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 

    RewriteRule ^(gallery/.+)$ /blog/$1 [L,NC] 
    RewriteRule ^gallery$ http://www.domainname.co.uk/blog/gallery/1$ [L,P] 

    RewriteRule . /index.php [L] 

</IfModule> 
+0

嗨阿尼爾..感謝您的答覆,但它不工作:(看起來像有在WordPress是一個問題的.htaccess? –

+0

在wordpress中有什麼問題?你可以​​指定,所以我可以幫你詳細嗎?上面的htaccess規則與wordpress一起工作,如果你再次測試它(如果你從上面複製我的舊htaccess代碼,我編輯它與我新的htaccess) – Anil