我有一个像这样的目录结构:
http://example.com/directory/folder/files/
我想用htaccess重写网址,以便用户访问时:
http://example.com/path/
它们来自http://example.com/directory/folder/files/
。
基本上,我想将directory/folder/files/
替换为path/
我该怎么做?
我此刻一直在尝试这个,但它不起作用,它只是在网址前面添加path
:
RewriteCond %{REQUEST_METHOD} =GET
RewriteRule ^directory/folder/files/$ path/%{REQUEST_URI} [L]
答案 0 :(得分:0)
您需要的规则与您尝试过的规则相反。试试这个规则:
RewriteCond %{REQUEST_METHOD} =GET
RewriteRule ^path/(.*)$ /directory/folder/files/$1 [L,NC]
答案 1 :(得分:0)
尝试在开头添加斜杠或
RewriteBase /