【问题标题】:Convert this string to another with Htaccess code使用 Htaccess 代码将此字符串转换为另一个字符串
【发布时间】:2014-10-08 15:06:42
【问题描述】:

我现在有这个网址:

new.php?news&post=111&title=XXXX

我想要这个网址:

new/news/111/XXXX

Htaccess 怎么做?

我试图用 mod_rewrite 转换它,但我做不到!

【问题讨论】:

    标签: php .htaccess url web url-rewriting


    【解决方案1】:

    试试这个

    RewriteRule ^/new/news/([^/]+)/([^/]+) /new.php?news&post=$1&title=$2
    

    【讨论】:

    • @Pafo 在浏览器中您提供的 URL 是 localhost/new/news/111/XXXX ??
    • TNx,我正在测试和修复我自己的代码,很快就会检查 ht 代码:X
    • 工作,但有一个新问题,如果我打开http://localhost/new/news/218/XXX/ 它会打开,但如果我打开http://localhost/fa/news/218/XXX(最后没有/,它不会打开!)如何解决这个问题?
    • 你想说http://localhost/new/news/218/XXX/ 可以工作,但http://localhost/new/news/218/XXX 不工作??
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-17
    • 1970-01-01
    • 2018-11-13
    • 2011-12-21
    • 1970-01-01
    • 2014-12-08
    相关资源
    最近更新 更多