本文介绍了重定向domain.com到domain.com/category不改变URL的地址栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要重定向为prestashop 1.5.3.1:当U型domain.com,你将被重定向到domain.com/category,但withou更改URL在浏览器地址栏中。怎么做?爱色丽现在我使用JavaScript的主题header.tpl这样

  {如果$ PAGE_NAME =='指数'}
<脚本>
window.location.href =htt​​p://www.domain.com/category;
< / SCRIPT>
{/如果}
 

是否有可能写一些htaccess的例子,我还是其他什么东西?非常感谢你。

下面是我的完整htaccess的:

 #~~开始~~不要删除这条评论,prestashop会自动保持在code此评论之外的.htaccess时,将再次产生
#的.htaccess automaticaly由prestaShop电子商务开源的解决方案产生
#HTTP://www.$p$pstashop.com  -  HTTP://www.$p$pstashop.com/forums

< IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteCond%{HTTP_HOST} ^ www.domain.com $
重写规则。 -  [E =的RewriteBase:/]
重写规则^ API /?(.*)$%{ENV:的RewriteBase}?Web服务/ dispatcher.php URL = $ 1 [QSA,L]

#图片
的RewriteCond%{HTTP_HOST} ^ www.domain.com $
重写规则^([0-9])(\  -  [_ A-ZA-Z0-9  - ] *)( -  [0-9] +)/.+ \ JPG $%?{ENV:的RewriteBase} IMG / P / $ 1 / $ 1 $ 2 $ 3.JPG [L]
的RewriteCond%{HTTP_HOST} ^ www.domain.com $
重写规则^([0-9])([0-9])(\  -  [_ A-ZA-Z0-9  - ] *)( -  [0-9] +)?/.+ \ JPG $% {ENV:的RewriteBase} IMG / P / $ 1 / $ 2 / $ 1 $ 2 $ 3 $ 4.JPG [L]
的RewriteCond%{HTTP_HOST} ^ www.domain.com $
重写规则^([0-9])([0-9])([0-9])(\  -  [_ A-ZA-Z0-9  - ] *)?( -  [0-9] +)/ + \ JPG $%{ENV:的RewriteBase}。IMG / P / $ 1 / $ 2 / $ 3 / $ 1 $ 2 $ 3 $ 4 $ 5.JPG [L]
的RewriteCond%{HTTP_HOST} ^ www.domain.com $
重写规则^([0-9])([0-9])([0-9])([0-9])(\  -  [_ A-ZA-Z0-9  - ] *)( -  [0 ?-9] +)/.+ \ JPG $%{ENV:的RewriteBase} IMG / P / $ 1 / $ 2 / $ 3 / $ 4 / $ 1 $ 2 $ 3 $ 4 $ $ 5 6.JPG [L]
的RewriteCond%{HTTP_HOST} ^ www.domain.com $
重写规则^([0-9])([0-9])([0-9])([0-9])([0-9])(\  -  [_ A-ZA-Z0-9-] *)( -  [0-9] +)/.+ \ JPG $%{ENV:的RewriteBase}?。IMG / P / $ 1 / $ 2 / $ 3 / $ 4 / $ 10 / $ 1 $ 2 $ 3 $ 4 $ $ 5 $ 6 7.JPG [ L]
的RewriteCond%{HTTP_HOST} ^ www.domain.com $
重写规则^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\  -  [_ A- ZA-Z0-9  - ] *)( -  [0-9] +)/.+ \ JPG $%{ENV:的RewriteBase}?。IMG / P / $ 1 / $ 2 / $ 3 / $ 4 / $ 5 / $ 6 / $ 1 $ 2 $ 3 $ 4 $ $ 5 $ 6 7 $ 8.JPG [L]
的RewriteCond%{HTTP_HOST} ^ www.domain.com $
重写规则^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9] )(\  -  [_ A-ZA-Z0-9  - ] *)( -  [0-9] +)/.+ \ JPG $%{ENV:的RewriteBase}?。IMG / P / $ 1 / $ 2 / $ 3 / $ 4 / $ 5 / $ 6 / $ 7 / $ 1 $ 2 $ 3 $ 4 $ $ 5 $ 6 7 $ $ 8 9.jpg [L]
的RewriteCond%{HTTP_HOST} ^ www.domain.com $
重写规则^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9] )([0-9])(\  -  [_ A-ZA-Z0-9  - ] *)( -  [0-9] +)/.+ \ JPG $%{ENV:的RewriteBase}?。IMG / p /$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L]
的RewriteCond%{HTTP_HOST} ^ www.domain.com $
重写规则^ C /([0-9] +)(\  -  [\ * _ A-ZA-Z0-9  - ] *)( -  [0-9] +)?/.+ \ JPG $%{ENV :的RewriteBase} IMG / C / $ 1 $ 2 $ 3.JPG [L]
的RewriteCond%{HTTP_HOST} ^ www.domain.com $
重写规则^ C /([A-ZA-Z _-] +)( -  [0-9] +)/.+ \ JPG $%{ENV:的RewriteBase}?IMG / C / $ 1 $ 2.JPG [L]

#调度
的RewriteCond%{} REQUEST_FILENAME -s [OR]
的RewriteCond%{} REQUEST_FILENAME -l [OR]
的RewriteCond%{} REQUEST_FILENAME -d
的RewriteCond%{HTTP_HOST} ^ www.domain.com $
。重写规则^ * $  -  [NC,L]
的RewriteCond%{HTTP_HOST} ^ www.domain.com $
。重写规则^ * $%{ENV:的RewriteBase}的index.php [NC,L]
< / IfModule>

#如果重写国防部未启用
ErrorDocument的404 /index.php?controller=404

#~~到底~~不要删除这条评论,prestashop会自动保持code此评论之外的.htaccess时,将再次产生
 

解决方案

尝试:

  RewriteEngine叙述上
的RewriteCond%{HTTP_HOST} ^(WWW \)?域\ .COM $ [NC]
重写规则^ /?(指数。\ PHP)?$ /类[L]
 

这仅适用于请求 http://domain.com/ http://domain.com/index.php ,你会得到供应 http://domain.com/category 的内容不改变URL地址栏中。你可能甚至可以失去的RewriteCond%{HTTP_HOST} ^(WWW \)?域\ .COM $ [NC] 行,如果你不需要它。

i need to redirect for prestashop 1.5.3.1:when u type domain.com, you will be redirected to the domain.com/category, but withou changing the url in browser address bar. how to do it?Rite now i am using javascript in theme header.tpl like this

{if $page_name == 'index'}
<script>
window.location.href="http://www.domain.com/category";
</script>
{/if}

Is it possible to write some htaccess example for me or something else? Thank you very much

Here is my complete htaccess:

# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
# http://www.prestashop.com - http://www.prestashop.com/forums

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]

# Images
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L]

# Dispatcher
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^.*$ - [NC,L]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
</IfModule>

#If rewrite mod isn't enabled
ErrorDocument 404 /index.php?controller=404

# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
解决方案

Try:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^/?(index.\php)?$ /category [L]

This only works for requests for http://domain.com/ or http://domain.com/index.php, and you'd get served the content at http://domain.com/category without changing the URL in the address bar. You can probably even lose the RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC] line if you don't need it.

这篇关于重定向domain.com到domain.com/category不改变URL的地址栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 07:09