重定向到内部路径.htaccess

时间:2015-02-10 11:23:37

标签: apache .htaccess redirect

我只是想从

重定向
  • mydomain.com/foo

  • mydomain.com/foo/bar

我的根.htaccess:

 <IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /
 RewriteRule ^index\.php$ - [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]
  </IfModule>

任何简单的答案都会非常感激。

1 个答案:

答案 0 :(得分:1)

您需要在重写中添加RewriteRule ^foo/?$ /foo/bar [R=302,L]

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /
 RewriteRule ^foo/?$ /foo/bar [R=302,L]
 RewriteRule ^index\.php$ - [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]
</IfModule>