使用 htaccess 更清晰的 url

发布于 2024-11-04 02:59:57 字数 622 浏览 3 评论 0原文

好的,我正在使用 opencart 这是一个开源购物车。我在此处安装了它,问题是,当您单击任何内容(我的意思是任何内容)时,网址会从这里变为

http://royaltyfreesoundbank.com/

最终

http://royaltyfreesoundbank.com/index.php?route=product/category&path=18

的内容正在发生的事情是

/index.php?route=CONTROLLER/VIEW

有道理的,但网址很难看,我想知道 htaccess 中是否有一种方法可以让所有页面失去这个中间部分,并让

http://royaltyfreesoundbank.com/product/category&path=18

任何人都有类似的想法......提前致谢

Ok so i am using opencart which is an open source shopping cart. I installed it here the problem is that when you click on anything and I mean anything the url goes from this

http://royaltyfreesoundbank.com/

to

http://royaltyfreesoundbank.com/index.php?route=product/category&path=18

so ultimately what is happening is that

/index.php?route=CONTROLLER/VIEW

which makes sense but the url is ugly and I was wondering if there was a way in htaccess that i can just make all the pages lose this middle portion and have it something like this

http://royaltyfreesoundbank.com/product/category&path=18

ideas anyone....thanks in advance

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

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

发布评论

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

评论(1

深居我梦 2024-11-11 02:59:57

此处:

# Turn on URL re-writing
RewriteEngine On

# Clean URLs
RewriteRule ^(.+)/(.+)/([0-9]+)/?$   /index.php?route=$1/$2&path=$3    [NC,L]

然后您可以使用以下网址访问它:

http://example.com/category/product/354

但请注意,这是一个相当广泛的规则,将匹配 anyfolder/anyfolder/45以及已知的类别/产品名称,因此,您可能需要对其进行调整以仅限于已知的类别。

Here:

# Turn on URL re-writing
RewriteEngine On

# Clean URLs
RewriteRule ^(.+)/(.+)/([0-9]+)/?$   /index.php?route=$1/$2&path=$3    [NC,L]

Then you would access it with urls like:

http://example.com/category/product/354

Note, however, that this is a rather broad rule which will match anyfolder/anyfolder/45 as well as known category/product names, so, you may want to tweak it to limit just to known categories.

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