动态URL重写htaccess的

编程入门 行业动态 更新时间:2024-10-25 06:33:57
本文介绍了动态URL重写htaccess的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个动态的URL重写的一个问题。

I have a problem with dynamic url rewriting.

我有两个不同的网址的,我需要重写的搜索引擎优化的目的。由于这些都不是固定的,而是动态的 - 我可以在htaccess的不只是设置规则如常。另外我也有一对夫妇的固定网址的。

I have two different kind of url’s that I need to rewrite for SEO purposes. Since these are not fixed, but dynamic – I can’t just setup rules in htaccess as usual. In addition I also have a couple of fixed URL's.

所有蛞蝓名称是唯一的,并存储在两个不同的表中我的数据库。

All slug names are unique, and are stored in two different tables in my database.

  • 产品名称(我有产品一个非常大的列表) www.domain/a-big-brown-bear.html (应指向view_product.php)

  • Product names (I have a very large list of products) www.domain/a-big-brown-bear.html (should point to view_product.php)

    类别(类别可以在两个层次) www.domain/cars/ford.html www.domain/cars.html

    Categories (The categories can be in two levels) www.domain/cars/ford.html www.domain/cars.html

    (这应该指向view_category.php,和菜单名称的两个级别应沿发送)

    (These should point to view_category.php, and both level of menu names should be sent along)

    什么是控制动态URL的最佳方式,同时还依靠htaccess的?可能有人知道一个类使用?

    What’s the best way of controlling dynamic urls, while still relying on htaccess? Possible someone knows a class to use?

    PS:我的问题是不是真的写的规则,但如何来从我的数据库的规则到htaccess的

    PS: My problem is not really writing the rules, but how to fetch the rules from my DB into htaccess.

    我怕我在做这个比较复杂的,它确实是。所有帮助是AP preciated!

    I’m afraid I’m making this more complicated that it really is. All help is appreciated!

    在此先感谢,

    问候

    推荐答案

    您有两个基本选择:

    • 捕获所有传入的请求(除了图片,样式表等)到服务器端的前端控制器(PHP,ASP,或者你使用任何服务器端语言),并用做重定向有头(....)。这是最简单和最流行的方式。

    • Catch all incoming requests (except for images, style sheets, etc.) into a server-side front controller (PHP, ASP or whatever server-side language you use), and do the redirection there using header(....). This is the easiest and most popular way.

    使用Apache的 RewriteMap指令 指令经常写你映射到文本文件,mod_rewrite的可以看看。

    Use Apache's RewriteMap directive to frequently write your maps into text files that mod_rewrite can look up.

    在 RewriteMap指令的变通办法是有益的特殊omptimization情景的许多的流量。通常情况下,机会是你富裕的第一个选项。

    The RewriteMap alternative might be beneficial in special omptimization scenarios with lots of traffic. Usually, chances are you're well off with the first option.

  • 更多推荐

    动态URL重写htaccess的

    本文发布于:2023-11-01 12:05:48,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1549286.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:重写   动态   URL   htaccess

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!