Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
.htaccess htaccess 301重定向子目录,但不重定向子目录内的任何内容_.htaccess_Redirect_Subdirectory - Fatal编程技术网

.htaccess htaccess 301重定向子目录,但不重定向子目录内的任何内容

.htaccess htaccess 301重定向子目录,但不重定向子目录内的任何内容,.htaccess,redirect,subdirectory,.htaccess,Redirect,Subdirectory,我有两个子目录/产品/行业/ 我想重定向如下: /products/industry to /products/#industry 但是,我不想重定向如下内容: /products/industry/product-name 或者任何可能跟随你/行业的东西。这是我的htaccess中的一些不起作用的东西。也许我很接近 RewriteEngine On RewriteCond %{REQUEST_URI} ^/products/industry[/]?$ RewriteRule (.*) /p

我有两个子目录/产品/行业/

我想重定向如下:

/products/industry to /products/#industry
但是,我不想重定向如下内容:

/products/industry/product-name
或者任何可能跟随你/行业的东西。这是我的htaccess中的一些不起作用的东西。也许我很接近

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/products/industry[/]?$
RewriteRule (.*) /products/#industry [R=301,L]
你可以做:

RewriteEngine On
RewriteBase /bti/

RewriteRule ^(products)/(industry)$ $1/#$2 [R=301,L,NE,NC]

在我的测试中,这将
/products/industry
重定向到
/products/#industry
您是否可以确保将此规则保留为第一条规则,并在新浏览器中尝试此规则。我将其修改为使用子目录。我仍然没有在多个浏览器中得到结果,并且清除了缓存。重写规则^(bti)/(产品)/(行业)$/$1/$2/#$3[R=301,L,NE,NC]这当然是放在名为
/bti/
的子目录中。我的整个网站是/bti子目录。当然,你没有在任何有问题的地方提到它