【问题标题】:HTACCESS | Social Engine | Stop redirecting Root index访问 |社交引擎 |停止重定向根索引
【发布时间】:2011-05-20 03:57:51
【问题描述】:

我目前安装了 SocialEngine,所有 url 都由 .htaccess 文件处理,该文件重定向到 socialengine.php 文件并处理漂亮的 URL 等。

我想阻止 example.com/ 被重定向到脚本,因为我想在那里放置一个不同的索引页面。所以我希望我的 .htaccess 文件处理它无法通过 socialengine.php 脚本找到的所有其他文件,但保持根文件转到 index.php。

所以如果是.com/,它会转到index.php,如果是其他任何东西,它会通过socialengine.php处理。

下面是我需要修改的 .htaccess 文件。

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On
  # Get rid of index.php
  RewriteCond %{REQUEST_URI} /socialengine\.php
  RewriteRule (.*) socialengine.php?rewrite=2 [L,QSA]
  # Rewrite all directory-looking urls
  RewriteCond %{REQUEST_URI} /$

  RewriteRule (.*) socialengine.php?rewrite=1 [L,QSA]
  # Try to route missing files
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} public\/ [OR]
  RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
  RewriteRule . - [L]

  # If the file doesn't exist, rewrite to index
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ socialengine.php?rewrite=1 [L,QSA]
</IfModule>

提前感谢您的任何回复。

【问题讨论】:

    标签: .htaccess url mod-rewrite root socialengine


    【解决方案1】:

    将下面的代码直接放在RewriteEngine On之后。

    RewriteCond %{REQUEST_URI} ^/$
    RewriteRule .* - [L]
    

    解释:第一行匹配到http://example.com/ 的请求(在这种情况下,REQUEST_URI 包含/)。第二行原封不动地传递请求(注意-)

    参考:
    http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule

    【讨论】:

      猜你喜欢
      • 2023-03-29
      • 1970-01-01
      • 2016-06-26
      • 1970-01-01
      • 1970-01-01
      • 2010-11-04
      • 2018-01-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多