代码点火器 +一台主机上的 Opencart -- URI 路由问题

发布于 2024-09-09 19:28:39 字数 256 浏览 9 评论 0原文

好吧,我搜索了论坛,但找不到任何具体答案。 网站和商店不一样。 Codeigniter 已用于处理所有内容,因此现在我想使用 Opencart 添加商店,而 URI 路由是问题所在。

(事实是,我不是 CI 粉丝,但既然我之前的人使用了它,我别无选择,只能继续,现在我必须沿着 CI 添加一个商店!)

我应该将网站与商店分开,并将每个商店放入主机上的单独文件夹并使用 .htaccess 重写规则来处理与每个 MVC 相关的 URI,或者我可以做一些简单的事情吗?

OK I searched the boards and could not found any specific answer.
the website and the shop aren't the same. Codeigniter has been used for handling everything so now I want to add a shop using Opencart and the URI routing is the problem.

(The truth is Im not a CI fan but since the guy before me used it I have no other choice but to continue and now I have to add a shop along CI!)

Should I separate the website from the shop and put each one into a separate folder on the host and use .htaccess rewrite rules to handle URI related to each MVC or can I do something simple?

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

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

发布评论

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

评论(1

苏别ゝ 2024-09-16 19:28:39

您应该能够在 CI“系统”文件夹的同一级别创建一个文件夹,您可以在其中复制所有商店文件。然后,您只需通过domain.com/shop/ 访问商店,

如果您已经拥有从CI url 中删除index.php 的默认.htaccess 文件,我认为您不需要更改任何路由或.htaccess 规则。我在几个网站上这样做,效果很好。

编辑:这是我的完整 .htaccess 文件,该文件可以正常工作的网站

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /    

    redirect 301 /disclaimer/disclaimer.html /disclaimer.html

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    #special rule to allow the 301 redirect from above
    RewriteCond %{REQUEST_URI} !disclaimer/disclaimer.html$ 

    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>



<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

#####################################################
# CONFIGURE media caching
#
Header unset ETag
FileETag None
<FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css)$">
Header unset Last-Modified
Header set Expires "Fri, 21 Dec 2012 00:00:00 GMT"
Header set Cache-Control "public, no-transform"
</FilesMatch>
#
#####################################################

<IfModule mod_deflate.c>
<FilesMatch "\.(js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>

You should be able to create a folder at the same level of your CI "system" folder and in there you can copy all the shop files. You then just access the shop via domain.com/shop/

I don't think you need to change any routing or .htaccess rules if you already have the default .htaccess file in place that removes index.php from the CI urls. I'm doing this on several sites and it works fine.

EDIT: here is my full .htaccess file for a site where this works fine

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /    

    redirect 301 /disclaimer/disclaimer.html /disclaimer.html

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    #special rule to allow the 301 redirect from above
    RewriteCond %{REQUEST_URI} !disclaimer/disclaimer.html$ 

    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>



<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

#####################################################
# CONFIGURE media caching
#
Header unset ETag
FileETag None
<FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css)$">
Header unset Last-Modified
Header set Expires "Fri, 21 Dec 2012 00:00:00 GMT"
Header set Cache-Control "public, no-transform"
</FilesMatch>
#
#####################################################

<IfModule mod_deflate.c>
<FilesMatch "\.(js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文