【发布时间】:2020-04-02 18:21:29
【问题描述】:
我有这样做的 .htaccess:https://example.com/john 显示目录 https://example.com/user/index.php?username=john 的内容
RewriteRule ^([a-zA-Z0-9_-]+)$ /user/index.php?username=$1 [QSA]
我怎样才能让https://example.com/john/blah 显示https://example.com/user/blah 的内容?如果应用了我之前的重写规则,则仅显示 /user 文件夹的内容。
例如:
example.com/john/haha ---> example.com/user/haha
example.com/privacy/blah ---> // Will show 404 page because /privacy is an actual page.
【问题讨论】:
-
@anubhava 抱歉,编辑了帖子。应该是
user/profile.php -
所以
/john/profile应该重写为/user/profile.php?username=john? -
@anubhava 我更改了帖子以使其更清晰。我想保留到目前为止的内容,但我也想:
/john/*显示/user/*的内容,如果应用了第一个重写规则。
标签: apache .htaccess mod-rewrite url-rewriting apache2