2011-09-07 44 views
0

我有URL重寫的問題。 我有一個安裝了wordpress的網站example.com。如何將example.com/ch重定向到子目錄/ rootdir/ch /?

我想在子目錄「/ ch-wordpress /」中添加另一個wordress實例並通過url「example.com/ch/....」提供。

我知道有很多關於url重寫的問題,但是我找不到能幫助我的那個。如果有人能夠幫助我,我將非常感激。

這裏是一個當期的URL重寫文本

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/

RewriteRule ^category/culture-news/(.*)$ /cognac-news/$1 [L,R=301] 
RewriteRule ^category/bottles/(.*)$ /cognac-reviews/$1 [L,R=301] 
RewriteRule ^category/rare-bottle-price-worth-information/(.*)$ /your-cognac-bottle/$1 [L,R=301] 
RewriteRule ^category/history-region-production/(.*)$ /what-is-cognac/$1 [L,R=301] 
RewriteRule ^category/cognac-drinks-cocktails/(.*)$ /cognac-drinks-cocktails/$1 [L,R=301] 

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

回答

0

忘記的.htaccess有一個更簡單的方法,在你的public_html creante的index.php文件並粘貼此

<?php 
header('Location: http://example.com/ch/....'); 
? 
> 

會重定向指數到你想要的目錄

編輯

你想重定向example.com/ch/$1" 到子文件夾「/ CH/

那好吧,你有一個文件夾名爲$ 1創建一個index.php文件,並將其放置在$ 1

<?php 
header('Location: http://example.com/ch/'); 
? 
> 

即使$ 1是一個文件,而不是一個文件夾,你可以在其中放置代碼,你會被重定向當你去它

試試吧,看看它是如何工作的。

+0

但我仍然希望主站點「example.com」起作用。 – simple

+0

你是什麼意思?你想從example.com重定向到example.com/folder,並且你想同時訪問example.com?請你解釋一下嗎?你可以刪除index.php – Lynob

+0

我想重定向「example.com/ch/$1」到子文件夾「/ ch /」 – simple