【问题标题】:Rewrite / to /mypage.html without redirect将 / 重写为 /mypage.html 而无需重定向
【发布时间】:2015-01-18 14:33:57
【问题描述】:

我要改首页

http://www.example.com/

显示来自

的内容
http://www.example.com/mypage.html

.htaccess only 方法请。

我不希望页面重定向。我需要主页显示来自同一网站的不同内容。从字面上切换主页现在改为显示类别页面。


这是当前的 magento .htaccess 文件

DirectoryIndex index.php
<IfModule mod_php5.c>
    php_value memory_limit 256M
    php_value max_execution_time 18000
    php_flag magic_quotes_gpc off
    php_flag session.auto_start off
    php_flag suhosin.session.cryptua off
    php_flag zend.ze1_compatibility_mode Off
</IfModule>

<IfModule mod_security.c>
    SecFilterEngine Off
    SecFilterScanPOST Off
</IfModule>

<IfModule mod_deflate.c>
</IfModule>

<IfModule mod_ssl.c>
    SSLOptions StdEnvVars
</IfModule>

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^/?$ /furniture/living-room.html
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
    RewriteRule .* - [L,R=405]
    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule .* index.php [L]
</IfModule>
    AddDefaultCharset Off
    AddDefaultCharset UTF-8
<IfModule mod_expires.c>
    ExpiresDefault "access plus 1 year"
</IfModule>
    Order allow,deny
    Allow from all
<Files RELEASE_NOTES.txt>
    order allow,deny
    deny from all
</Files>

我的网站是http://www.onemegamarket.com/

【问题讨论】:

  • RewriteRule 默认不重定向,它是内部重写。 RewriteRule ^/?$ /mypage.html 不行吗?
  • 没有不同,我现在将完整的 .htaccess 添加到原始问题
  • 您正在堆叠多个重写规则。最后一条规则.* index.php 将匹配。要尽早打破您的主页规则,请添加 [L](最后一个)标志。
  • 我不确定这是默认的 magento .htaccess

标签: apache .htaccess mod-rewrite


【解决方案1】:

[L] 标志添加到您的重写规则中,以避免匹配全部内容。

RewriteRule ^/?$ /furniture/living-room.html [L]

【讨论】:

  • Plus1,现在的首页肯定是展示家具了。也许丹尼尔只需要清除他的浏览器缓存。
猜你喜欢
  • 2013-04-17
  • 1970-01-01
  • 2015-10-24
  • 2021-12-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多