0

我有一个当前位于“ http://domain.com/subdir/folder1 ”的页面。/folder1/ 之后有很多目录,例如“folder1/bananas/stock/”“folder1/apples/stock/order/”等。我试图找到一种从“domain.com/”中获取页面的方法subdir/folder1/bananas”,例如,如果我输入了“domain.com/subdir/fruits/bananas”,则在重定向后将“fruits”保留在 URL 中。

这是我能够想出的代码:(我实际上什至不知道它的正确百分比)

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/subdir/fruits/.*$
RewriteRule ^(.*)$ /subdir/folder1/$1

我无法正确找到允许在“fruits”之前或之后编写任何子目录分别替换“folder1”的语法。有时 URL 可能是“domain.com/customer/subdir/fruits”,所以我的目标是尝试找到“之前的所有内容”的语法,而不是 ^,它只是表示域之后的所有内容,如果我没错的话。

与往常一样,我感谢任何时间或致力于解决此问题的帮助。谢谢!

编辑:这是我的目标的另外几个例子:

User types into webaddress:
http://www.domain.com/subdir/fruits/bananas/stock/refund
page gets information from:
http://www.domain.com/subdir/folder1/bananas/stock/refund
User sees URL in address box:
http://www.domain.com/subdir/fruits/bananas/stock/refund
/* -------- */
User types into webaddress:
http://www.domain.com/subdir/customer/fruits/apples/review
Page gets information from:
http://www.domain.com/subdir/customer/folder1/apples/review
User sees URL in address box:
http://www.domain.com/subdir/customer/fruits/apples/review
/* -------- */
User types into webaddress:
http://www.domain.com/subdir/customer/fruits/cherries/season-listing
Page gets information from:
http://www.domain.com/subdir/customer/folder1/cherries/season-listing
User sees URL in address box:
http://www.domain.com/subdir/customer/fruits/cherries/season-listing
4

0 回答 0