通过不同文件夹中的.htaccess文件将abc.com重定向到opencart中的www.abc.com
我在两个文件夹中安装了opencart——一个是根文件夹,即“public_html/”,另一个是“public_html/test/”。两个opencart都包含.htaccess文件 “public_html/”文件夹上opencart的.htaccess文件包含以下重写规则:通过不同文件夹中的.htaccess文件将abc.com重定向到opencart中的www.abc.com,.htaccess,redirect,opencart,.htaccess,Redirect,Opencart,我在两个文件夹中安装了opencart——一个是根文件夹,即“public_html/”,另一个是“public_html/test/”。两个opencart都包含.htaccess文件 “public_html/”文件夹上opencart的.htaccess文件包含以下重写规则: RewriteBase / RewriteRule sitemap.xml /new/index.php?route=feed/google_sitemap RewriteCond %{REQUEST_FILENAM
RewriteBase /
RewriteRule sitemap.xml /new/index.php?route=feed/google_sitemap
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^abcd\.co\.in
RewriteRule (.*) http://www.abcd.co.in/$1 [R=301,L]
RewriteBase /test/
RewriteRule sitemap.xml /new/index.php?route=feed/google_sitemap
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
“public_html/test/”文件夹中opencart的.htaccess文件包含以下重写规则:
RewriteBase /
RewriteRule sitemap.xml /new/index.php?route=feed/google_sitemap
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^abcd\.co\.in
RewriteRule (.*) http://www.abcd.co.in/$1 [R=301,L]
RewriteBase /test/
RewriteRule sitemap.xml /new/index.php?route=feed/google_sitemap
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
问题是当我打开域http://abcd.co.in它将重定向到http://www.abcd.co.in,但当我打开http://abcd.co.in/test
它不是重定向
让我http://www.abcd.co.in/test您的重定向规则不适用。另外,
.htaccess
也应限制在与之关联的文件夹中,请在我的头顶尝试以下操作:
RewriteBase /test/
RewriteRule sitemap.xml /test/index.php?route=feed/google_sitemap
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) /test/index.php?_route_=$1 [L,QSA]
如果你点击网址
http://abcd.co.in/test/
如果在public\u html/test/
文件夹中有另一个.htaccess
文件,则不计算public\u html
根文件夹中的.htaccess
文件。您应该通过以下方式扩展public\u html/test/.htaccess
:
RewriteBase /test/
RewriteRule sitemap.xml /new/index.php?route=feed/google_sitemap
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^abcd\.co\.in/test/
RewriteRule (.*) http://www.abcd.co.in/test/$1 [R=301,L]
这应该可以解决问题。严格来说,
.htaccess
并没有被考虑在内。它是从.htaccess
目录上方的文件也被应用后读取的,但是,由于重写库
不正确,因此在这种情况下不会被应用。这是正确的修复方法,但是so+1:)