0

翻訳にはmod_rewriteを使用する必要があります。

http://example.com/sitengoFrontEnd3/lista/tipo-todo/?terminos=abcd

の中へ:

http://example.com/sitengoFrontEnd3/lista/tipo-todo/abcd

私はcodeigniterフレームワークを使用しています。

私の.htaccessは次のとおりです。

RewriteEngine On
RewriteBase /sitengoFrontEnd3

# Esto es para el formulario de busqueda
RewriteCond %{QUERY_STRING} terminos=(.*)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1%1? [L]

# Esto para el codeigniter
RewriteCond %{REQUEST_URI} ^sitengoFrontEnd3.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

このシナリオでは:

閲覧先:

http://example.com/sitengoFrontEnd3/lista/tipo-todo/?terminos=abcd

結果は(同じ):

http://example.com/sitengoFrontEnd3/lista/tipo-todo/?terminos=abcd

LogRewriteレベル9を貼り付けます。

(3) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] add path info postfix: /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/lista -> /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/lista/tipo-todo/
(3) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] strip per-dir prefix: /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/lista/tipo-todo/ -> lista/tipo-todo/
(3) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] applying pattern '^(.*)$' to uri 'lista/tipo-todo/'
(4) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] RewriteCond: input='terminos=abcd' pattern='terminos=(.*)'  > matched
(4) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] RewriteCond: input='/Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/lista' pattern='!-f' => matched
(4) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] RewriteCond: input='/Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/lista' pattern='!-d' => matched
(2) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] rewrite 'lista/tipo-todo/' -> 'index.php/lista/tipo-todo/abcd?'
(3) split uri=index.php/lista/tipo-todo/abcd? -> uri=index.php/lista/tipo-todo/abcd, args=<none>
(3) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] add per-dir prefix: index.php/lista/tipo-todo/abcd -> /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/index.php/lista/tipo-todo/abcd
(2) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] trying to replace prefix /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/ with /sitengoFrontEnd3
(5) strip matching prefix: /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/index.php/lista/tipo-todo/abcd -> index.php/lista/tipo-todo/abcd
(4) add subst prefix: index.php/lista/tipo-todo/abcd -> /sitengoFrontEnd3/index.php/lista/tipo-todo/abcd
(1) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] internal redirect with /sitengoFrontEnd3/index.php/lista/tipo-todo/abcd [INTERNAL REDIRECT]
(3) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] add path info postfix: /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/index.php -> /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/index.php/lista/tipo-todo/abcd
(3) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] strip per-dir prefix: /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/index.php/lista/tipo-todo/abcd -> index.php/lista/tipo-todo/abcd
(3) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] applying pattern '^(.*)$' to uri 'index.php/lista/tipo-todo/abcd'
(4) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] RewriteCond: input='' pattern='terminos=(.*)' => not-matched
(3) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] add path info postfix: /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/index.php -> /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/index.php/lista/tipo-todo/abcd
(3) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] strip per-dir prefix: /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/index.php/lista/tipo-todo/abcd -> index.php/lista/tipo-todo/abcd
(3) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] applying pattern '^(.*)$' to uri 'index.php/lista/tipo-todo/abcd'
(4) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] RewriteCond: input='/sitengoFrontEnd3/index.php/lista/tipo-todo/abcd' pattern='^sitengoFrontEnd3.*' => not-matched
(3) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] add path info postfix: /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/index.php -> /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/index.php/lista/tipo-todo/abcd
(3) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] strip per-dir prefix: /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/index.php/lista/tipo-todo/abcd -> index.php/lista/tipo-todo/abcd
(3) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] applying pattern '^(.*)$' to uri 'index.php/lista/tipo-todo/abcd'
(4) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] RewriteCond: input='/Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/index.php' pattern='!-f' => not-matched
(1) [perdir /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/] pass through /Applications/XAMPP/xamppfiles/htdocs/sitengoFrontEnd3/index.php

.htaccessのこの行を変更した場合:

RewriteRule ^(.*)$ index.php/$1%1? [L]

この他の外部のものに:

RewriteRule ^(.*)$ http://example2.com/$1%1? [L]

次に、参照すると:

http://example.com/sitengoFrontEnd3/lista/tipo-todo/?terminos=abcd

結果:

http://example2.com/lista/tipo-todo/abcd

では、なぜそれは内部と相対ではなく、外部と絶対のために機能しているのでしょうか?私はこれを解決しようとして成功せずに一日を失ったので、どんな助けも歓迎します。

4

1 に答える 1

0

Ok。コメントしてくださってありがとうございます。最後に、次の .htaccess で解決しました。

    RewriteEngine On
    RewriteBase /sitengoFrontEnd3


    # Esto es para el formulario de busqueda
    #RewriteCond %{REQUEST_URI} ^sitengoFrontEnd3.*
    RewriteCond %{QUERY_STRING} terminos=(.*)
    #RewriteCond %{REQUEST_FILENAME} !-f
    #RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ %{REQUEST_URI}%1? [R=301,L]



    # Esto para el codeigniter
    RewriteCond %{REQUEST_URI} ^sitengoFrontEnd3.*
    RewriteRule ^(.*)$ /index.php/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
于 2013-01-12T14:39:03.733 に答える