使用 .htaccess 我想在 URL 末尾添加特定文本。在下面的示例中,我想在用户访问时在 URL 末尾添加单词“Hello”
https://example.com/aboutus/
用户输入的网址:
https://example.com/aboutus/
URL 重写为:
https://example.com/aboutus/Hello
注意:如果用户输入
https://example.com/aboutus/Hello
URL 应保留
https://example.com/aboutus/Hello
我是 .htaccess 新手
我使用 .htaccess 已经有一段时间了,但是你可以了:
# Check if your request already containts 'Hello' at the end
RewriteCond %{REQUEST_URI} !/Hello/?$
# Apply the rule for the path "/aboutus" or "/aboutus/"
RewriteRule ^aboutus/?$ /aboutus/Hello [L,R=301]