使用 .htaccess 重写文件夹名称添加斜杠
Rewrite a folder name add slash using .htaccess
是否可以使用 .htaccess
重写文件夹名称,在名称中添加 斜线 ?
假设我有一个 url 像:
example.com/sub-directory/page.php
现在我想将 url 重写为:
example.com/sub/directory/page.php
这应该有效
RewriteEngine on
RewriteRule ^([^-]+)-([^/]+)/([^.]+)\.php$ ///.php [NC,L]
上面的正则表达式^([^-]+)-([^/]+)/([^.]+).php$将匹配以任何字符(非 -)开头,后跟 - 后跟任何字符(非 -),再后跟 / 的任何请求任何字符(不是点)后跟 .php 。如果匹配则请求将被重写为 /sub/dir/file.php .
是否可以使用 .htaccess
重写文件夹名称,在名称中添加 斜线 ?
假设我有一个 url 像:
example.com/sub-directory/page.php
现在我想将 url 重写为:
example.com/sub/directory/page.php
这应该有效
RewriteEngine on
RewriteRule ^([^-]+)-([^/]+)/([^.]+)\.php$ ///.php [NC,L]
上面的正则表达式^([^-]+)-([^/]+)/([^.]+).php$将匹配以任何字符(非 -)开头,后跟 - 后跟任何字符(非 -),再后跟 / 的任何请求任何字符(不是点)后跟 .php 。如果匹配则请求将被重写为 /sub/dir/file.php .