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]

重写不起作用但在.htaccess中出现内部错误
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- dtutlamjasblef7982 2013-12-10 15: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]
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报