Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 如何使用.htaccess进行重定向?_Apache_.htaccess_Web - Fatal编程技术网

Apache 如何使用.htaccess进行重定向?

Apache 如何使用.htaccess进行重定向?,apache,.htaccess,web,Apache,.htaccess,Web,我想知道的是,使用.htaccess可以实现一些技巧(重定向) site.org/member/$var>site.org/member/?id=$var,如下所示 关键是在$var之前添加?id(字符串常量) 会是这样的 重新启动发动机 重写规则(或重写匹配) 干杯。这允许您将整个网站重定向到任何其他域 Redirect 301 / http://mt-example.com/ 这允许您将index.html重定向到特定的子文件夹 Redirect /index.html http://ex

我想知道的是,使用.htaccess可以实现一些技巧(重定向)

site.org/member/$var>site.org/member/?id=$var,如下所示

关键是在$var之前添加?id(字符串常量)

会是这样的

重新启动发动机

重写规则(或重写匹配)


干杯。

这允许您将整个网站重定向到任何其他域

Redirect 301 / http://mt-example.com/

这允许您将index.html重定向到特定的子文件夹

Redirect /index.html http://example.com/newdirectory/
将旧文件路径重定向到新文件路径

Redirect /olddirectory/oldfile.html http://example.com/newdirectory/newfile.html
提供特定索引页(设置默认处理程序)

详情如下:

详情见:

htaccess基础知识:

尝试:

RewriteCond %{QUERY_STRING} !id=
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^members/(.+)$ /member/?id=$1 [L,QSA]
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
RewriteRule ^(.*)/member/(.*)$ $1/member/?id=$2 [L]
RewriteCond %{QUERY_STRING} !id=
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^members/(.+)$ /member/?id=$1 [L,QSA]