0

我想重写

  • www.mydomain.com/www/whatever.php

  • www.mydomain.com/www/whatever.php?hl=EN

whatever.php 不是固定的,它代表 www 目录中的任何 php 页面。

我的 htaccess 目前看起来像这样:

RewriteEngine on
RewriteCond %{REQUEST_URI} !hl=
RewriteRule ^(.+)$ $1?hl=EN [QSA,R=301,L]

但由于某种原因,它会将每个页面的真实硬盘路径添加到 www.mydomain.com,例如:

  • 127.0.0.1:8080/index.php

变成

  • 127.0.0.1:8080/D:/mypath/index.php?hl=EN

我一定在这里做错了什么,知道吗?

4

1 回答 1

1

你可以试试这个:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI}  ^/(www/[^.]+\.php)/? [NC]
RewriteRule .*         %1?h1-EN             [R=301,L]

永久重定向

http://www.mydomain.com/www/whatever.php带或不带斜杠

到:

http://www.mydomain.com/www/whatever.php?hl=EN

假定所有字符串都是固定的,除了whatever.

对于静默映射,替换[R=301,L][L]


从 SO 编辑:

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} !hl=
RewriteCond %{REQUEST_URI}  ^/(www/[^.]+\.php)/? [NC]
RewriteRule .*         %1?hl=EN             [R=301,L]

成功了,谢谢

于 2013-02-19T23:45:27.613 回答