Apache 如何使用.htaccess进行重定向?
我想知道的是,使用.htaccess可以实现一些技巧(重定向) site.org/member/$var>site.org/member/?id=$var,如下所示 关键是在$var之前添加?id(字符串常量) 会是这样的 重新启动发动机 重写规则(或重写匹配)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
干杯。这允许您将整个网站重定向到任何其他域
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]