【问题标题】:How to hide the 1st variable in this url with .htaccess?如何使用 .htaccess 隐藏此 url 中的第一个变量?
【发布时间】:2015-08-08 21:33:35
【问题描述】:

blah.com/numberVariable/variable2.html

我想在 URL 中隐藏数字变量。

这是我当前的代码:

RewriteCond %{QUERY_STRING} action=(.*)
RewriteRule ^([1-9][0-9]*)/([-.,_0-9a-zA-z]*)\.html$  details.php query_string=$1&action=%1 [L]
RewriteRule ^([1-9][0-9]*)/([-.,_0-9a-zA-z]*)\.html$  details.php?query_string=$1 [L]

【问题讨论】:

    标签: php regex apache .htaccess mod-rewrite


    【解决方案1】:

    试试这个正则表达式:

    \/[^\/\n]+
    

    Regex live here.

    解释:

    \/           # match the first '/' character
    [^\/\n]+     # and anything till the next '/' character or till the line's end
    

    我假设/numberVariable 是第一个文件夹

    希望对你有帮助。

    【讨论】:

    • 我可以得到一些有关 htaccess 代码的帮助吗?每当我进行更改时,它都会进入重定向循环。有人能解释一下我的代码行是什么意思吗?
    • @neo。好吧,我不是htaccess 专家。但我找到了这个答案:stackoverflow.com/q/4318171/4227915
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-17
    • 2015-07-25
    • 1970-01-01
    相关资源
    最近更新 更多