【问题标题】:Why does my url for my website have a ?. Already changed .htaccess为什么我的网站网址有一个?。已更改 .htaccess
【发布时间】:2014-03-13 15:42:44
【问题描述】:

我正在使用 ExpressionEngine 作为我网站的 CMS。我创建了一个带有以下内容的 .htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Removes index.php from ExpressionEngine URLs
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteCond %{REQUEST_URI} !/system/.* [NC]
    RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

    # Directs all EE web requests through the site index file
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{HTTP_HOST} ^www.gsmastersinc.com$ [NC]
    RewriteRule ^(.*)$ http://gsmastersinc.com/$1 [R=301,L]
</IfModule>

为什么我网站的所有网址都有一个 ?在他们中?前任。 myurl/?/contact.

你可以在这里看到我在说什么:http://gsmastersinc.com,然后点击任何导航链接。悬停时,它不显示?,只有在单击它之后。

我必须拥有 ?在第 13 行的 /index.php 或链接断开后,我得到 404。

我整个上午都在寻找答案,但出现的一切都与 .NET 或类似的东西有关。

谢谢

【问题讨论】:

    标签: regex apache .htaccess mod-rewrite expressionengine


    【解决方案1】:

    更改规则的顺序:

    RewriteEngine On
    RewriteBase /
    
    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{HTTP_HOST} ^www.gsmastersinc.com$ [NC]
    RewriteRule ^(.*)$ http://gsmastersinc.com/$1 [R=301,L]
    # Removes index.php from ExpressionEngine URLs
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteCond %{REQUEST_URI} !/system/.* [NC]
    RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
    
    # Directs all EE web requests through the site index file
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    

    通常在内部重写规则之前保留您的 301 规则。

    【讨论】:

    • 伙计,我不确定除了订单有什么不同,但您的解决方案效果很好。非常感谢!
    • 是的,由于底部出现 301 规则,它正在重定向内部重写的 URL。
    猜你喜欢
    • 2012-09-15
    • 2014-06-12
    • 2012-01-22
    • 2015-10-23
    • 1970-01-01
    • 1970-01-01
    • 2016-01-27
    • 2015-03-04
    • 1970-01-01
    相关资源
    最近更新 更多