【发布时间】:2012-12-16 07:19:01
【问题描述】:
我想将所有具有 .html 扩展名的链接重定向到一个带有目录 + 页面名称作为 get 参数的 process.php 文件。我已经尝试过这些link1link2 解决方案,但它不起作用。
例如
http://localhost/Site/directory1/test1.html
http://localhost/Site/directory2/test2.html
重定向到 process.php 为
http://localhost/Site/process.php?directory1/test1.html
http://localhost/Site/process.php?directory2/test2.html
我试过这样。
RewriteEngine on
RewriteRule ^/(.*).html /process.php?page=$1
还有这个
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*/)?([^/]*)\.php$ /process.php?page=$2 [R=301,L]
但它不起作用。
请查看并提出任何可行的方法。
【问题讨论】:
-
“它不起作用”不是问题。什么是 webroot 目录? .htaccess 文件的完整路径是什么?请启用重写日志并从日志中复制以显示 mod_rewrite 而不是的作用。此外,您使用了错误的术语。您的问题与重定向无关。
标签: mod-rewrite