【发布时间】:2013-05-01 14:58:29
【问题描述】:
有很多问题讨论重写模组问题。我读过它们,但没有一个能解决我独特的问题。我已经做了 3 个小时的研究来解决它,但我仍然卡住了。
我想重写通过file_get_contents() PHP 函数从远程站点检索到的源代码中的链接。
当我得到源代码时,链接结构是:
<a href='javascript:openWindow("index1.php?option=com_lsh&view=lsh&event_id=148730&tv_id=850&tid=34143&channel=0&tmpl=component&layout=popup&Itemid=335","735","770")' >Link#1</a>
我想改写成:
<a href='javascript:openWindow("http://remotesite.com/index1.php?option=com_lsh&view=lsh&event_id=148730&tv_id=850&tid=34143&channel=0&tmpl=component&layout=popup&Itemid=335","735","770")' >Link#1</a>
经过一些研究,我认为 rewrite mod 可以解决问题。我试图将下面的代码放在我的 .htaccess 文件中:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^index1\.php?option - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule http://remotesite/index1.php?option [L]
但是,它给了我内部服务器错误。
我在这里做错了什么?有没有其他方法可以按照上面描述的方式重写链接结构?
【问题讨论】:
-
我不认为使用 .HTACCESS 对你来说是最好的解决方案。我认为使用正则表达式匹配和字符串替换是最好的。
-
我知道,但现在我上面的 htaccess 代码出了什么问题
-
那么除了htaccess之外最好的方法是什么