删除URL中的双斜杠并删除index.php Apache [英] Remove double Slashes in URL and remove index.php Apache

查看:51
本文介绍了删除URL中的双斜杠并删除index.php Apache的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢您阅读我的问题.

我有一个在Apache Web服务器上运行的应用程序(php)(目前在旧的Apache 2.2.17上).现在,我将Apache升级到2.4.18.

i have an application (php) running on Apache webserver (at the moment on an old apache 2.2.17). Now i will upgrade the Apache to 2.4.18.

要从URL中删除index.php,有一个.htaccess文件.这个规则.

For removing the index.php from the url there is an .htaccess file. with this rules.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php/$0 [PT,L]  

在某些请求上,应用程序会创建

On some requests the application creates post requests like

http://www.xyz.yz//targetname/targetname2/

网址路径中的

双斜杠//.

double slashes // in the url path.

在Apache 2.2.17上,此URL没有任何问题,但是Apache 2.4.18创建了404错误.

On Apache 2.2.17 there was no problem with this urls, but Apache 2.4.18 creates an 404 error.

我在重写规则方面发挥了很多作用:

I played lot of with rewrite rules like this:

RewriteCond %{REQUEST_URI} ^(.*)//(.*)$ [NC]
RewriteRule . %1/%2 [R=307,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php/$0 [PT,L]  

但是现在客户端发送了两次发布请求.因此,如何在不重写的情况下告诉apache忽略"双引号.

But now the client sends the post request twice. So how can i tell apache "ignore" double quotes without rewrite for example.

感谢您的想法和解决方案.

Thanks for ideas and solutions.

推荐答案

要在域扩展后删除多个斜杠,可以在htaccess中的其他规则之前使用以下规则:

To remove multiple slashes after the domain extension, you could use the following rule before othe Rules in htaccess:

RewriteEngine on

RewriteCond %{THE_REQUEST} //+(.+)\sHTTP
RewriteRule ^ /%1 [L,R]

这会将多个斜杠转换为一个,

This will convert multiple slashes into one,

  • example.com////foo

  • example.com/foo

这篇关于删除URL中的双斜杠并删除index.php Apache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆