【发布时间】:2012-11-22 06:19:31
【问题描述】:
我在 Url Rewriting 的世界里还是个新手。我必须在我们自己的 CMS 中这样做,以获得一个好看的 url 并获得一个更好的结构,从而通过搜索引擎 (SEO) 提供结果。
这是完成我们现在用漂亮的 URL 隐藏的所有工作的背景文件:
这是我的结构模式的一个例子:
CMS 只需在 FR 目录中创建一个 HTACCESS 文件,用于非常基本的重写,如下所示:
Options +FollowSymlinks
RewriteEngine On
RewriteRule produits/solives-de-rive-rimboard index.php?p=144
RewriteRule produits/decoupe-sur-mesure index.php?p=145
RewriteRule produits/panneaux-osb index.php?p=146
RewriteRule produits/boites-de-bois-crates index.php?p=147
RewriteRule produits/palettes-de-bois index.php?p=148
RewriteRule accueil index.php?p=4
RewriteRule a-propos-de-cimdat index.php?p=139
RewriteRule produits index.php?p=140
RewriteRule videos index.php?p=141
RewriteRule nous-joindre index.php?p=142
对于像“accueil”、“nous-joindre”这样的第一级页面,一切正常......
但我还没有找到像“produits/solives-de-rive-rimboard”这样的二级和三级页面的解决方法。 index.php 只是加载正常,只是到此页面的所有相关链接都是一个子文件夹(css、图像、jquery...)。
我是否可以在 htaccess 文件中使用任何标签来指定索引在哪个级别“accueil”、“produits/something”或第三级,如“produits/group/something”。 php有基本路径吗?
我更喜欢在 htaccess 中寻找解决方法,而不是给 index.php 一个“<base href="something">”,这可能会给我们的结构带来其他问题。
谢谢
【问题讨论】:
-
这些是替换 URL,真实的。但是请求的 URL 是怎样的呢?至少一个例子来找出模式。换句话说,如果可能的话,给出一个在浏览器地址栏中输入的 URL 以及要重定向到的相应重写 URL 的示例。
-
对 url 替换感到抱歉...刚刚更新了我的初始帖子!
标签: apache .htaccess url-rewriting