如何删除多个斜线的URI与'preG'或'的.htaccess“(how to remove multiple slashes in URI with 'PREG' or 'HTACCESS')

   IT问题网   2018-08-12 00:00:00

问 题

如何删除多个斜线的uri与'preg"或".htaccess的"

site.com/edition/new ///- > site.com/edition/new /


site.com/edition ///新的/- > site.com/edition/new /

感谢

解决方案

使用正则表达式的加号 + 是指一个或一个以上的previous的发生字符。因此,我们可以在preg_replace添加它通过只是其中之一来替换一个或多个 / 发生

$ url ="site.com/edition/new///";

$的newurl = preg_replace('/(\ / +)/','/',$网址);

//现在应该更换正确的单斜杠
回声$的newurl
 

标签:如何删除斜线或者



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

&功放;&QUOT与urlen code和&QUOT PHP $ _GET变种;错误(PHP $_GET var with urlencode and "&" bug)

problem in my code, i create a link like this: $link = ' ...

要如何把所有子目录使用的htaccess或httpd.conf来根?(How can I redirect all sub-directories to root using htaccess or httpd.conf)

problem i have an index file that builds cont ...

如何包括所有HTTP请求PHP脚本来服务器(How to include a php script in all HTTP requests coming to the server)

problem i have a file called init.php which i want to get ...

htaccess的不允许用户查看我的文件夹的文件不具有的index.php(.htaccess don't allow user to view my folder files that don't have index.php)

problem on my server, i've created a folder t ...

htaccess的PHP 5.3的选择打破访问控制 - 允许 - 产地的选择吗?(.htaccess PHP 5.3 option breaks Access-Control-Allow-Origin option)

problem let me first say that i am running on a shared li ...

重定向1 TLD的另一个所有页面(Redirect all pages of one TLD to another)

problem \i'm darn nearly pulling my hair out trying to fi ...

无法删除301重定向(Cannot remove 301 redirect)

problem i stupidly did a 301 redirect on websitea.com to ...

htaccess的重定向到删除的index.php(htaccess redirect to remove index.php)

problem i want user to be able use $_server['path_info'] ...

htaccess的重定向到子域,并保持串(htaccess redirect to subdomain and keep string)

problem found a few similar questions but either i cant f ...

逃避mod_rewrite的正则表达式句点(。)字符(escape period (.) character in mod_rewrite regex)

problem i currently have a .htaccess file set up with thi ...

Backbone.js的路由器使用pushstate与本地主机上的XAMPP Apache服务器(Backbone.js router using pushstate with XAMPP apache server on localhost)

problem i'm trying to get backbone.js's router to work wi ...

限制POST请求的服务器(Restrict POST Request The Server)

problem i want to restrict all post request t ...

重定向所有域别名之一,htaccess的(Redirecting all domain aliases to one with htaccess)

problem i have a few domain aliases, while i ...

隐藏参数(查询字符串)的URL(htaccess的),但发送该参数的页面(PHP)(hide parameter (query string) in url (htaccess) but send this parameter to a page (php))

problem how to hide parameters (query_string) in url but ...

htaccess的UTF-8的.html,的.css,.js文件编码 - 最新最好的方法是什么?(htaccess UTF-8 encoding for .html, .css, .js - Whats the best way)

problem for yslow page speed i want to remove my meta tag ...

的.htaccess文件夹虚拟文件夹重写(.htaccess folder to virtual-folder rewriting)

problem is it possible with apache's rewriteengine to do ...

如何让CakePHP的2.X的子目录出现在根(与mod_rewrite的htaccess的)?(How to make cakePHP 2.x in sub directory appear in root (with mod_rewrite in htaccess))

problem i'm working on an cake app which is inside a sub ...

Apache的重定向 - 的.htaccess - 的RewriteCond(Apache Redirects - .htaccess - ReWriteCond)

problem i'm trying to manipulate the .htaccess file on my ...

如何阻止IP地址的POST请求,但没有得到什么呢?(How to block IPs for POST requests, but not GET)

problem i have a website where i'm getting qu ...

如何使用Apache重写时隐藏URL的变化?(How to hide the URL change when using apache rewrite)

problem how do i hide the url change when using an apache ...