2010-11-18 36 views
2

は、私が使用htaccessの短縮URL

www.site.com/laptopする

www.site.com/product/info/laptopを短くしたい

RewriteRule ^(.+)$ /product/info/$1 

しかし、私は500内部サーバーエラーを取得

私が試してみると

RewriteRule ^([a-zA-Z0-9_\s\'~%,:!?()_=&-]+)$ /product/info/$1 

それは動作しますが、私も期間をサポートしたいので、含めてください。

RewriteRule ^([a-zA-Z0-9_\s\'~%,:!?()\._=&-]+)$ /product/info/$1 

それはあなたが何が起こっているか説明してもらえ

私に500内部サーバーエラーを与えますか? 「移動とwww.example.com/laptopするwww.example.com/product/info/laptopからブラウザをリダイレクトします

RewriteCond %{REQUEST_URI} ^/product/info/(.*)$ 
RewriteRule ^(.*)?$  /%2     [R=301,L] 

+0

なぜ二重引用符?式は[a-zA-Z0-9_ \ s \ '〜%、:!()\ ._ =& - ] + –

答えて

0

は、以下のことを試してみてくださいありがとう永久に "ヘッダー。あなたは、内部で長いURLを指すように短いURLをご希望の意味ならば、あなたは、円形のリダイレクトを回避しなければなりません

RewriteRule ^product/info/.*$ -    [L] # don't redirect again 
RewriteRule ^(.*)$   /product/info/$1 [L] # redirect everything else 

最初の行はwww.example.com/product/をリダイレクトしようと停止しますinfo/laptop to 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 
+0

でなければなりません。 /私は短いURLが内部で長いURLを指すように望むので、私のhtaccessは今 するRewriteCondの%{REQUEST_URI}^/製品/情報/(.*)$ のRewriteRule ^製品/情報に – user257867

+0

RewriteEngineのように見えます。 * $ - #リダイレクトしません。 RewriteRule ^(。他のすべてのリダイレクト RewriteCond $ 1!^(index \ .php | img | phpmyadmin | images | user | wmd | FCKeditor | map | jscalendar | aurigma | xajax_js | css | js |含める| floatbox |ヘルパー|スタイル|アヤックス|ロボット\ .txtファイル|ファビコンの\ .ICO) するRewriteRule ^(*)$ /index.php?$1 [L] が、今、これは私に サーバーエラーが発生します。! サーバーで内部エラーが発生し、要求を完了できませんでした。サーバーが過負荷になっているか、エラーがありました。 – user257867

+0

私は上記の答えを更新しました。それらの[L]を維持する必要があります。そうしないと、さらにルールを処理し続けるでしょう。 –