我正在使用下面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
到
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
答案 0 :(得分:3)
OpenCart .htaccess
规则的最后一行基本上捕获任何内容然后停止。在RewriteBase
行之后尝试你的两行,因为它应该工作。 .htaccess
文件逐行检查,最后一条OC行L
中的[L,QSA]
表示在该行运行后停止
答案 1 :(得分:0)
我们遇到了一个不同的问题,即OpenCart SEO Urls没有显示出来。所有Google搜索都指向我们启用mod_rewrite。我们问题的解决方案与其他人发布的解决方案略有不同,所以我想我会分享其他人可能会找到的地方。
我们的平台:
-Linux 2.6.32-042stab111.11版 (root@kbuild-rh6-x64.eng.sw.ru)(gcc version 4.4.6 20120305(Red Cap 4.4.6-4)(GCC))#1 SMP Tue Sep 1 18:19:12 MSK 2015
-CentOS版本6.8(最终)-Kernel \ r在\ m
上
服务提供商:railsplayground.com
我们正确地创建了我们的.htaccess文件,如OpenCart所指定的那样 cp .htaccess.txt .htaccess
但这打破了OpenCart向我们展示的所有页面。
在咬牙切齿之后,我们开始在.htaccess文件中注释掉不同的行。
结果是第一行
Options +FollowSymlinks
打破我们的链接。删除此行完全使SEO URL工作正常。
此外,请确保在搜索引擎优化网址之前或之后不要使用/。
希望这可以帮助别人。