swfAddress、mod_rewrite 和 SEO 的 URL 问题

发布于 2024-10-17 00:11:21 字数 477 浏览 6 评论 0原文

大家好,我有一个完整的深度链接 Flash 网站,我正在编写一个 php 脚本,该脚本将在页面上动态生成替代内容。

我无法让 swfaddress 的 SEO 版本正常工作,因此我尝试采用另一种方式。

到目前为止,这就是它的工作方式 - 我的可抓取链接如下所示:

mydomain.com?id=video ----->重写为: mydomain.com/video/

php 脚本读取 id 并准备适当的内容。问题是,当用户单击 Flash 内容时,他们的网址显示如下:

mydomain.com/video/#contact,
mydomain.com/video/#about-us
等等

这令人困惑。有没有办法用 PHP 或 javascript 去掉 uri 路径中的“/video/”?有什么想法或不可能吗?

Hey guys, I've got a full Flash website that's deeplinked and I'm working on a php script that will dynamically generate the alternate content on the page.

I can't get the SEO version of swfaddress to work so I'm trying to go around another way.

This is how it works so far - my crawlable links are like this:

mydomain.com?id=video -----> is rewritten as: mydomain.com/video/

The php script reads the id and prepares the appropriate content. Problem is, when users click on the flash content, their urls appear like this:

mydomain.com/video/#contact,
mydomain.com/video/#about-us
etc etc

Which is confusing. Is there a way to get rid of "/video/" in the uri path with PHP or javascript? Any ideas or not possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤城病女 2024-10-24 00:11:21

对于任何可能与我处境相同的人;努力理解 Asual 的 swfAddress SEO 解决方案,我得到了一个令人满意的结论。

我使用了单个index.php 和支持datasource.php,其中包含switch 语句中的所有结果。 switch 语句首先在index.php 中调用,并通过从通过GET 发送的id(例如?id=video)收集以下信息来运行。然后 switch 语句继续匹配适当的内容,设置变量供脚本的其余部分使用。我使用了以下内容:

<代码>
$标题
$描述
$关键字
$canonical // 提示:-> 'domain/video?id=somevid' 到 'domain.com/video/'(参见 google 中的规范)
$样式表
$正文

在 datasource.php 之后,我在其下面添加了一个“head.php”,它获取 html 滚动、doctype 等(但主要关注 )并列出关键字、描述和内容。内容,特定于该页面。

Swfaddress javascript 将为 Flash 用户设置深度链接:


SWFAddress.setValue(< ?php echo "/$id" ?>); // 例如“/video”

index.php 使用 swfobject 来嵌入 - 我使用静态嵌入(我听说某处它对 SE 更好,更具未来性,但谁知道呢,不过我更喜欢它)。替代内容是一个 div,它与之前提取的存储的 $body 相呼应。

最后,我使用 mod_rewrite 来设置我的可抓取链接。在测试过程中,我直接引用我的文件。

<代码>
< IfModule mod_rewrite.c >
选项 +FollowSymLinks
选项+索引
重写引擎开启
RewriteBase /

RewriteRule ^home/? ?id=home [NE,L]
RewriteRule ^about/? ?id=about [NE,L]
RewriteRule ^video/? ?id=video [NE,L]

< /if模块>

这可确保我的链接如下所示: http://www.mydomain.com/video/

其结果是: http://mydomain.com?id=video

搜索引擎可以抓取它完美地,仅查看 html 内容,用户将看到 Flash,当他们单击链接时,他们将看到如下内容:

http://www.mydomain.com/video/#/contact

正如我所说,它令人满意,虽然不如 Asual 的 SEO 解决方案那么理想,但足够干净。我在任何地方都找不到有关 swfaddress' SEO 示例的任何信息,而且我当然不知道足够的 php 来深入研究大量未注释的代码。

哦,请务必将其包含在您的index.php 的头部中,它将确保当您的swf 加载外部文件时您的链接不会出错。

<代码>< base href="http://www.mydomain.com/" />

希望能在某个时候对某人有所帮助。

To anyone who may be in the same position as me; struggling to understand Asual's swfAddress SEO solution I've reached a satisfactory conclusion.

I've used a single index.php and supporting datasource.php which contains all results in a switch statement. The switch statement is called first in the index.php and runs through collecting the following info from an id (eg. ?id=video) sent via GET. The switch statement then continues to match up appropriate content, setting variables for the rest of the script to use. I've used the following:


$title
$description
$keywords
$canonical // hint: -> 'domain/video?id=somevid' to 'domain.com/video/' (see canonical in google)
$stylesheet
$body

After the datasource.php, I include a "head.php" below it, which gets the html rolling, doctype etc (but is mostly concerned with the < head >) and lays out the keywords, description and content, specific to that page.

Swfaddress javascript will set the deeplinking upon entry for Flash users:


SWFAddress.setValue(< ?php echo "/$id" ?>); // eg."/video"

The index.php uses swfobject to embed - I use static embedding (I heard somewhere it was better for SE, more future proof but who knows, I prefer it though). The alternate content is a div, which echos the stored $body extracted earlier.

Finally I use mod_rewrite to setup my crawlable links. During testing I'm referencing my files directly.


< IfModule mod_rewrite.c >
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /

RewriteRule ^home/? ?id=home [NE,L]
RewriteRule ^about/? ?id=about [NE,L]
RewriteRule ^video/? ?id=video [NE,L]

< /ifModule >

This ensures my links look like this: http://www.mydomain.com/video/

Which results in: http://mydomain.com?id=video

A search engine can crawl it perfectly, viewing only the html content where as users will see the flash, and when they click on the links they will see something like this:

http://www.mydomain.com/video/#/contact

As I said it's satisfactory, not as ideal as Asual's SEO solution, but clean enough. I couldn't find ANY information on swfaddress' SEO sample anywhere, and I certainly don't know enough php to dive into the vast uncommented code.

Oh, be sure to include this in the head of your index.php, it will ensure your links don't screw up when your swfs load external files.

< base href="http://www.mydomain.com/" />

Hope that helps someone at some point.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文