我的网页目前位于“http://domain.com/subdir/folder1”。 / folder1 /之后有相当多的目录,例如“folder1 / bananas / stock /”“folder1 / apples / stock / order /”等等。我试图找到一种方法从“domain.com/”抓取页面subdir / folder1 / bananas“例如,如果我输入”domain.com/subdir/fruits/bananas“,则在重定向后在URL中保留”fruits“。
这是我能够提出的代码: (我实际上甚至不知道它的百分比是正确的)
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