duangai2831 2013-12-10 06:48
浏览 65
已采纳

重写不起作用但在.htaccess中出现内部错误

RewriteEngine On
RewriteRule ^http://example.lk/example1/ln1/([^/]*)$ http://example.lk/example1?ln1=$1 [L]
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^/?$ "http\:\/\/example\.lk\/ln\/1" [R=301,L]

RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^contactus$ "http\:\/\/example\.lk\/example3\/cm\/" [R=301,L]

RewriteCond %{HTTP_HOST} ^example\.lk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.lk$
RewriteRule ^example2$ "http\:\/\/example\.lk\/example2\/a\/\$1" [R=301,L]

RewriteCond %{HTTP_HOST} ^example\.lk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.lk$
RewriteRule ^example4$ "http\:\/\/example\.lk\/example4\?\/vi\/\$1" [R=301,L]

RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^example6$ "http\:\/\/example\.lk\/example6\/id\/\$1" [R=301,L]


RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^example1$ "http\:\/\/example\.lk\/example1\/ln2\/\$1" [R=301,L]
  • 写回答

1条回答 默认 最新

  • dtutlamjasblef7982 2013-12-10 07:00
    关注

    As pointed out, there a number of errors, please read the manual.

    You don't need to double quote or escape the redirect substitutions.

    You don't need to match the ${HTTP_HOST} if you don't care what it is.

    You can't have a $1 in the substitution without a matching group in the pattern.

    I've tried to fix some of the problems... but you need to provide more information on what specifically doesn't work and what you're trying to achieve.

    RewriteEngine On
    RewriteRule ^example1/ln1/([^/]*)$ http://example.lk/example1?ln1=$1 [L]
    
    # RewriteCond %{HTTP_HOST} ^.*$
    RewriteRule ^/?$ http://example.lk/ln/1 [R=301,L]
    
    # RewriteCond %{HTTP_HOST} ^.*$
    RewriteRule ^contactus$ http://example.lk/example3/cm/ [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^example\.lk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.example\.lk$
    RewriteRule ^example2$ http://example.lk/example2/a/ [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^example\.lk$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.example\.lk$
    RewriteRule ^example4$ http://example.lk/example4/vi/ [R=301,L]
    
    #RewriteCond %{HTTP_HOST} ^.*$
    RewriteRule ^example6$ http://example.lk/example6/id/ [R=301,L]
    
    #RewriteCond %{HTTP_HOST} ^.*$
    RewriteRule ^example1$ http://example.lk/example1/ln2/ [R=301,L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?