【问题标题】:URL redirect not working with .htaccess not workingURL 重定向不适用于 .htaccess 不起作用
【发布时间】:2014-10-12 22:09:01
【问题描述】:

我正在尝试为我在服务器中托管的几个调查提供更好的 URL。

这就是我所做的。

  • 在服务器的 /var/www 目录中(与 index.php 文件所在的位置相同),我创建了一个文件 .htaccess。
  • 下面是.htaccess文件的内容:

    RewriteEngine On
    RewriteRule goodURL BadURL
    Redirect goodURL BadURL
    

请注意 goodURL (midnightsun.hiit.fi/socialnetworking) 是不存在的,而 BadURL(midnightsun.hiit.fi/limesurvey/index.php/755819) 是存在的。

我要更改此 URL 重定向的原因是提供良好的 URL。

Debian GNU/Linux 7.6 (wheezy) 是服务器上的操作系统。 它是 Apache2。

谁能帮我解决这个问题?

【问题讨论】:

  • 使用其中之一但不能同时使用:1) Redirect /socialnetworking https://midnightsun.hiit.fi/limesurvey/index.php/755819 或 2) RewriteRule ^socialnetworking$ limesurvey/index.php/755819
  • 也许你的工具已经有一个 htaccess 文件(LimeSurvey 已经有很多年了......)。重定向(在现有规则之前)是最好的方法。
  • @DenisChenu。谢谢你的参与。你能帮我看看它应该是什么样子吗?目前它就像pastebin.com/6h8jMBk3

标签: apache .htaccess mod-rewrite redirect limesurvey


【解决方案1】:
Redirect temp /liliurl http://example.org/index.php/755819

<IfModule mod_rewrite.c>
    RewriteEngine on

    # if a directory or a file exists, use it directly
    RewriteCond %{REQUEST_FILENAME} !-f

    # otherwise forward it to index.php
    RewriteRule . index.php
</IfModule>
# General setting to properly handle LimeSurvey paths
# AcceptPathInfo on

【讨论】:

    猜你喜欢
    • 2018-08-18
    • 1970-01-01
    • 2014-11-25
    • 2015-09-06
    • 1970-01-01
    • 2011-10-28
    • 2023-03-27
    • 2015-03-07
    • 2015-08-01
    相关资源
    最近更新 更多