嘗試以下操作:
RewriteCond %{REQUEST_URI} ^/product/info/(.*)$
RewriteRule ^(.*)?$ /%2 [R=301,L]
將在瀏覽器重定向www.example.com/product/info/laptop用「感動到www.example.com/laptop永久性「標題。
如果你的意思是你想的更短的URL指向長URL內部,則必須避免循環重定向:
RewriteRule ^product/info/.*$ - [L] # don't redirect again
RewriteRule ^(.*)$ /product/info/$1 [L] # redirect everything else
第一線將停止嘗試重定向www.example.com/product/ info/laptop到www.example.com/product/info/product/info/laptop,等等。
編輯
基於您的評論,它看起來像你也試圖重定向除了IMG公司的phpmyadmin,等等一切,無論指數 - ?你都有點現在重新安排,有些東西像這樣:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/(index\.php|img|phpmyadmin|images|user|wmd|FCKeditor|map|jscalendar|aurigma|xajax_js|css|js|include|floatbox|helper|styles|ajax|robots\.txt|favicon\.ico|product/info/(.*))
RewriteRule ^(.*)$ - [L] # don't redirect these
RewriteRule ^(.*)$ /product/info/$1 # redirect everything else
我不是第一次重寫的「product/info /(.*)」部分的100%。如果還是不行,請嘗試以下:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/(index\.php|img|phpmyadmin|images|user|wmd|FCKeditor|map|jscalendar|aurigma|xajax_js|css|js|include|floatbox|helper|styles|ajax|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ - [L] # don't redirect these
RewriteRule ^product/info/.*$ - [L] # don't redirect again
RewriteRule ^(.*)$ /product/info/$1 [L] # redirect everything else
編輯2
最終的答案基於您的評論:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/(index\.php|img|phpmyadmin|images|user|wmd|FCKeditor|map|jscalendar|aurigma|xajax_js|css|js|include|floatbox|helper|styles|ajax|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ - [L] # don't redirect these
# pass controllers to index.php
RewriteCond %{REQUEST_URI} ^/(home|browse|calendar|star|member|enter|product)
RewriteRule ^(.*)$ /index.php?$1 [L]
# pass other things than controllers to /index.php?/product/info/$1
RewriteRule ^(.*)$ /index.php?/product/info/$1 [L] # redirect everything else
爲什麼雙引號?表達式應該是[a-zA-Z0-9_ \ s \'〜%,:!?()\ ._ =& - ] + – 2010-11-18 05:33:11