使用.htaccess重定向到子文件夹

时间:2017-03-27 13:18:44

标签: php .htaccess redirect

我有以下系统文件夹:

.htaccess

- www
  - index.html
  - assets
  - dev
  - prod

当您访问域名的网址(www.example.com)时,您会看到index.html

好吧,我只想重定向到每个ip的子文件夹prod,但我的。我试过这个:

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^ myIP
RewriteRule http://www.example.com/prod/ [L]

谢谢。

1 个答案:

答案 0 :(得分:0)

试试这个

RewriteEngine on
RewriteRule ^prod/(.*)$ /$1 [R=301,L]

请参考: http://beginnersbook.com/2013/08/redirect-subdirectory-to-root-using-htaccess/