【问题标题】:Replace string in URL using apache [closed]使用apache替换URL中的字符串[关闭]
【发布时间】:2015-01-30 17:17:52
【问题描述】:

我是 apache 网络服务器的新手。

我有一个类似的网址:-

www.example.com/example1/{ dynamic string }/p123465/content

我想把它转换成:

www.example.com/example1/{ dynamic string }/pid/content

这里的动态字符串每次都不一样。

【问题讨论】:

  • 两者看起来一样有什么区别
  • 两个网址都没有区别
  • 对不起,我已经编辑了问题。

标签: regex apache apache2


【解决方案1】:

您可以在 DOCUMENT_ROOT/.htaccess 文件中使用此代码:

RewriteEngine On
RewriteBase /

RewriteRule ^(example1/[^/]+)/p123465/(content)/?$ /$1/pid/$1 [L,NC,R]

或者如果你已经有/example1/.htaccess,那么使用

RewriteEngine On
RewriteBase /example1/

RewriteRule ^([^/]+)/p123465/(content)/?$ $1/pid/$1 [L,NC,R]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-06
    • 2014-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-08
    • 2014-03-06
    • 1970-01-01
    相关资源
    最近更新 更多