【问题标题】:htaccess send content after ? as a parameterhtaccess 之后发送内容?作为参数
【发布时间】:2017-01-16 06:27:00
【问题描述】:

这是我的输入网址

http://site_name/project/edit/sgdsg/getFile/?file=271bbec45d7855a332e6dfda85ca94b9.txt

我希望它像这样发送 http://site_name/project/edit/sgdsg/getFile/271bbec45d7855a332e6dfda85ca94b9.txt

我们怎样才能做到这一点?我只希望以 http://site_name/project/edit/sgdsg/getFile/ 开头的 URL 所以它不会影响任何其他 URL。

这是我尝试过的......

RewriteRule ^project/edit/([A-Za-z0-9._-]+)/([A-Za-z0-9._-]+)/([A-Za-z0-9._-]+)/?$ modules-nct/edit_project-nct/index.php?slug=$1&action=method&method=$2&file=$3 [L]
RewriteRule ^project/edit/([A-Za-z0-9._-]+)/([A-Za-z0-9._-]+)/?$ modules-nct/edit_project-nct/index.php?slug=$1&action=method&method=$2 [L]
RewriteRule ^project/edit/([A-Za-z0-9._-]+)/?$ modules-nct/edit_project-nct/index.php?slug=$1 [L]

请不要因为我的编辑不当就给它负面评价。我是来学习新东西的。

谢谢。

【问题讨论】:

    标签: php regex .htaccess url-rewriting


    【解决方案1】:

    在您的<a> 标签中:

    <a href="your_url/your_other_parameters(means :project/edit/sgdsg/getFile/ )/directly enter your file name that you want to pass"> i.e your <a> tag must be
    
    <a href="http://site_name/project/edit/sgdsg/getFile/271bbec45d7855a332e6dfda85ca94b9.txt"></a>
    

    在 htaccess 中:

    RewriteRule ^project/edit/([A-Za-z0-9._-]+)/([A-Za-z0-9._-]+)/([A-Za-z0-9._-]+)$ modules-nct/edit_project-nct/index.php?slug=$1&action=method&method=$2&file=$3
    

    在上述行中,href URL 将被重定向到原始 URL。

    【讨论】:

    • 重点不在于我应该如何调用 url,而在于如何处理它......不过,谢谢队友..
    猜你喜欢
    • 1970-01-01
    • 2014-01-22
    • 2014-01-30
    • 1970-01-01
    • 2011-08-03
    • 1970-01-01
    • 1970-01-01
    • 2015-05-10
    • 1970-01-01
    相关资源
    最近更新 更多