1

我在下面使用opencart的默认.htaccess文件,我手动添加了最后两行。

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

RewriteCond %{REQUEST_URI} diger_olcu_aletleri
RewriteRule ^diger_olcu_aletleri$ http://www.hirdavatdeposu.com/diger-olcu-aletleri

我已经使用网站(http://htaccess.madewithlove.be/)进行了检查,它改变了我的网址

diger_olcu_aletleri

迪格-奥尔库-阿莱莱里

正如预期的那样,但它在我的网站上不起作用。可能是什么问题?

下面是我完整的 .htaccess 文件。

# 1.To use URL Alias you need to be running apache with mod_rewrite enabled. 

# 2. In your opencart directory rename htaccess.txt to .htaccess.

# For any support issues please visit: http://www.opencart.com

Options +FollowSymlinks

# Prevent Directoy listing 
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
 Order deny,allow
 Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/ 

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

RewriteCond %{REQUEST_URI} diger_olcu_aletleri
RewriteRule ^diger_olcu_aletleri$ http://www.hirdavatdeposu.com/diger-olcu-aletleri

### Additional Settings that may need to be enabled for some servers 
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off

# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off

# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M

# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M

# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200

# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200
4

2 回答 2

3

OpenCart.htaccess规则的最后一行基本上捕获任何东西然后停止。在该行之后尝试您的两行,RewriteBase因为这应该可以。.htaccess文件逐行检查,最后 OC 行的inL表示[L,QSA]在该行运行后停止

于 2013-01-06T13:23:01.797 回答
0

我们遇到了一个不同的问题,即未显示 OpenCart SEO Urls。所有 Google 搜索都指向我们启用 mod_rewrite。我们的问题的解决方案与其他人发布的略有不同,所以我想我会在其他人也可能找到的地方分享。

我们的平台:

-Linux 版本 2.6.32-042stab111.11
(root@kbuild-rh6-x64.eng.sw.ru) (gcc 版本 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC)) #1 SMP Tue Sep 1 18:19:12 MSK 2015

-CentOS release 6.8 (Final) - 内核 \r 在一个 \m

服务提供商:railsplayground.com

我们正确地创建了 .htaccess 文件,因为 OpenCart 指定了 cp .htaccess.txt .htaccess

但这破坏了 OpenCart 向我们展示的所有页面。

咬牙切齿之后,我们开始在 .htaccess 文件中注释掉不同的行。

结果是第一行

         Options +FollowSymlinks

破坏了我们的链接。完全删除这一行使 SEO URLS 工作得很好。

此外,请确保在 SEO URL 之前或之后不要有 /。

希望这可以帮助某人。

于 2016-12-20T23:31:26.853 回答