【问题标题】:SeoUrl and .htacces settingsSeo Url 和 .htaccess 设置
【发布时间】:2012-09-30 18:48:34
【问题描述】:

我尝试让我的网站在我访问时使用 seo 运行 mysite.com/search/eminem/1/video.html 给我这个网址的结果 mysite.com/index.php?search=eminem&page=1&type=video 它向我显示了搜索页面,但没有结果没有图像或 javascripts 等。就像 css 和 js 没有实现

这是我的 .htacces 代码

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^search/(.*)/(.*)/(.*).html?$ index.php?search=$3&page=$2&type=$1 [L]
<IfModule mod_deflate.c>
        <FilesMatch "\.(php|js|css|mp3|wmv|flv|html|htm)$">
            SetOutputFilter DEFLATE
        </FilesMatch>
    </IfModule>
</IfModule>

【问题讨论】:

  • 你的规则是文件。 1-尝试添加RewriteBase /。 2- 错误代码是什么?
  • 我查看了谷歌浏览器中的控制台错误。没有显示任何错误。就像 css 和 js 甚至没有包含在我的 index.php 中,或者它直接跳转到 search.php 而不使用 index.php,这就是我在 index.php 中包含 search.php &lt;?php if (isset($_GET['search'])) include('search.php'); else include('templates/home.php'); ?&gt;
  • 我试过 RewriteBase / 还是一样。还有一件事。我的站点和 .htaccess 文件位于 mysite.com/test/ 目录中,但我认为这不是原因,或者如果是,请告诉我。
  • 您的 htaccess 文件中还有其他规则吗?
  • 不,我的 htaccess 文件与我发布的完全一样。我正在使用 ubuntu 服务器,并且我有另一个脚本非常适合 seo 重写。

标签: .htaccess url seo


【解决方案1】:

您要么需要将所有相对链接(用于图像、CSS、JavaScript 等)设置为带有前导斜杠的绝对链接,要么将其添加到 index.php 内容的标题中:

<base href="/">

【讨论】:

  • Jon Lin 我试过你的代码。不工作。就像它不考虑 index.php 并直接跳转到 search.php 和 css 和 javascripts 不包括在内。我只是得到没有装饰或运行任何脚本的搜索 html。当我点击搜索时,我会得到这样的网址mysite.com/search/eminem/1/video.html?search=eminem&amp;page=1&amp;type=video
  • 我发现问题出在我的 apache2 服务器上。感谢您的代码 Jon Lin,它非常有用
猜你喜欢
  • 2019-04-23
  • 2013-02-03
  • 2015-04-17
  • 2013-11-06
  • 2011-05-29
  • 2013-01-22
  • 1970-01-01
  • 1970-01-01
  • 2013-01-11
相关资源
最近更新 更多