2011-07-04 35 views
0

號碼,我想每一個網址重定向包含在最終數子域:的.htaccess只能重定向的URL包含在最終

http://example.com/773 to http://blog.example.com/773 

,而不是重定向的URL包含字符串是這樣的:

http://example.com/web or http://example.com/web/shop or http://example.com/about 

我用這htaccess的代碼:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{REQUEST_URI} ^/[0-9] 
RewriteRule (.*) http://blog.example.com/$1 [R=301,L] 
</IfModule> 

但這htaccess的代碼重定向的URL是這樣的:

http://example.com/773 to http://blog.example.com/blog/773 

回答

0

下面的規則只會重定向這種類型的URL:http://example.com/773。如果URL將如http://example.com/somfolder/773(在路徑中有一些文件夾),則不會發生任何事情。

RewriteEngine On 
RewriteBase/

RewriteRule ^(\d+)$ http://blog.example.com/$1 [R=301,L] 
+0

非常感謝,工作正常! – sharktech