.htaccess permalinks
我有一个.htaccess文件,其中包含以下内容:.htaccess permalinks,.htaccess,mod-rewrite,apache2,.htaccess,Mod Rewrite,Apache2,我有一个.htaccess文件,其中包含以下内容: RewriteRule^page/(.*[^/])/?$index.php?page=$1,它基本上将page/1/转换为index.php?page=1,并且工作正常。但是如何强制index.php?page=1在浏览器中显示为page/1/?您只需使用L标志即可。像这样: RewriteRule ^page/(.*[^/])/?$ index.php?page=$1 [L,NC] 添加了NC标志以使正则表达式比较不区分大小写 这样,请求
RewriteRule^page/(.*[^/])/?$index.php?page=$1
,它基本上将page/1/
转换为index.php?page=1
,并且工作正常。但是如何强制index.php?page=1
在浏览器中显示为page/1/
?您只需使用L标志即可。像这样:
RewriteRule ^page/(.*[^/])/?$ index.php?page=$1 [L,NC]
添加了NC标志以使正则表达式比较不区分大小写
这样,请求的URLhttp://example.com/page/1/例如,
始终显示在浏览器的地址栏中,并且不会替换为替换URL:http://example.com/index.php?page=1