【发布时间】:2021-08-16 02:52:13
【问题描述】:
我的目标是使用 .htaccess 将 http://ipaddress/directory/file.php?id=47 重定向到 http://ipaddress/directory/47。 id 参数会有所不同,可以是任何数字字符串,例如 1、2、3、10、20、300 等。我当前的 .htaccess 文件如下:
RewriteEngine on
RewriteCond %{QUERY_STRING} id=([0-9]+) [NC]
RewriteRule (.*) /directory/%1? [R=301,L]
重写确实将网址更改为我想要的!但是在被重定向后我得到一个错误,它指出,Not Found - The requested URL was not found on this server.我不确定为什么重定向有效,但没有加载上一个页面id 参数和实际的 PHP 文件。
谢谢!
【问题讨论】:
标签: .htaccess redirect mod-rewrite url-rewriting friendly-url