Opencart 的 SEO 友好 URL 在 Codeigniter 中不工作
SEO friendly URL of opencart not working inside Codeigniter
我有一个主要基于代码 igniter.Inside 的网站,我有一个使用 opencart.Everything 的商店设置工作正常,直到我尝试使用 opencart seo 友好 urls。
完成后,它会显示 codeigniter 404 视图。
当 url 是 xyz 时,如何绕过 CI 路由。com/store
我的 Htaccess 文件在这里 :
# Customized error messages.
ErrorDocument 404 index.php
# Set the default handler.
DirectoryIndex index.php
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/ [L,QSA]
#RewriteCond %{HTTPS} off
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.(.*)
RewriteRule (.*) http://www.%{HTTP_HOST}/ [R=301,L]
</IfModule>
问题可能是由您的 .htaccess
文件引起的。默认的 Codeigniter .htaccess
文件设置为将所有流量路由到您的 public 目录 index.php。为防止这种情况,您需要设置一个 RewriteCond
以排除任何您希望保留在 codeigniter 之外的目录。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(store[^/]*)$
RewriteRule ^(.*)$ index.php?/ [L,QSA]
RewriteCond %{HTTP_HOST} !^www\.(.*)
RewriteRule (.*) http://www.%{HTTP_HOST}/ [R=301,L]
</IfModule>
我有一个主要基于代码 igniter.Inside 的网站,我有一个使用 opencart.Everything 的商店设置工作正常,直到我尝试使用 opencart seo 友好 urls。
完成后,它会显示 codeigniter 404 视图。
当 url 是 xyz 时,如何绕过 CI 路由。com/store
我的 Htaccess 文件在这里 :
# Customized error messages.
ErrorDocument 404 index.php
# Set the default handler.
DirectoryIndex index.php
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/ [L,QSA]
#RewriteCond %{HTTPS} off
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.(.*)
RewriteRule (.*) http://www.%{HTTP_HOST}/ [R=301,L]
</IfModule>
问题可能是由您的 .htaccess
文件引起的。默认的 Codeigniter .htaccess
文件设置为将所有流量路由到您的 public 目录 index.php。为防止这种情况,您需要设置一个 RewriteCond
以排除任何您希望保留在 codeigniter 之外的目录。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(store[^/]*)$
RewriteRule ^(.*)$ index.php?/ [L,QSA]
RewriteCond %{HTTP_HOST} !^www\.(.*)
RewriteRule (.*) http://www.%{HTTP_HOST}/ [R=301,L]
</IfModule>