本文介绍了国防部重写从URL中删除的文件夹名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 OJS 和我有一个名为刊物文件夹中安装它。我创造了一些期刊有(例如journal1,journal2,等等)。

现在我得到这样的路径: www.example.com/journals/index.php/journal1 www.example.com/journals/index.php/journal2 等。

我要的是地图 www.example.com/journals/index.php/journal1 以貌似 www.example.com/index.php/journal1 (删除日志部分来自URL)。

我不能移动OJS根,因为我有一些其他的文件存在。

下面是我现在用目前的.htaccess 文件(这是在杂志文件夹,并给了我一个500)

 < IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteCond $ 1!^期刊
重写规则^(。*)/期刊/ $ 1 [L]
< / IfModule>
 

另外这里是error.log中

  [周五10月12日22时16分45秒2012] [错误] [客户127.0.0.1]请求超过了10内部重定向的限制,由于可能的配置错误。使用'LimitInternalRecursion'如果有必要提高限制。使用LogLevel的调试,以得到一个回溯。
 

解决方案

当你把htaccess文件里面的这些规则在 /期刊目录,它造成了重写循环。 $ 1 从来没有开始,杂志,因为你的期刊目录中,因此该规则不断得到应用。

您需要把这样的事情在你的htaccess的文件在您的站点根目录的,在 / 目录:

  RewriteEngine叙述上
的RewriteCond%{REQUEST_URI}!^ /杂志
重写规则^指数\的.php(。*)$ /journals/index.php$1 [L]
 

I am using OJS and I have installed it inside a folder called "journals". I have created some journals there (for example "journal1", "journal2", etc).

Now I am getting paths like this: www.example.com/journals/index.php/journal1,www.example.com/journals/index.php/journal2, etc.

What I want is to map www.example.com/journals/index.php/journal1to looks like www.example.com/index.php/journal1 (removing the journal part from URL).

I can't move OJS to root because I have some other files there.

Here is the .htaccess file which I am using currently (it's in "journals" folder and giving me a 500)

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^journals
RewriteRule ^(.*) /journals/$1 [L]
</IfModule>

Also Here is the error.log

[Fri Oct 12 22:16:45 2012] [error] [client 127.0.0.1] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace. 
解决方案

When you put those rules inside the htaccess file in your /journals directory, it's causing a rewrite loop. $1 never starts with journals because you're inside the journals directory, thus the rule keeps getting applied.

You'll need to put something like this in your htaccess file in your site-root, the / directory:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/journals
RewriteRule ^index\.php(.*)$ /journals/index.php$1 [L]

这篇关于国防部重写从URL中删除的文件夹名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 20:33