【问题标题】:.htaccess - Dynamic URL redirecting.htaccess - 动态 URL 重定向
【发布时间】:2018-01-25 15:50:10
【问题描述】:

我想动态重定向 URL。我尝试了很多 .htaccess 组合,但没有一个对我有用。

这是我的动态网址:http://localhost/verload.php?name=example

这是我想要的网址:http://localhost/example

而且我需要排除我希望只有http://admin.localhost/ 才能访问的目录“loader”和“admin”。

可以这样做吗?

谢谢

编辑:我不想更改 URL。我只想让http://localhost/example 指向http://localhost/verload.php?name=example。我希望现在很清楚。

【问题讨论】:

    标签: php regex apache .htaccess redirect


    【解决方案1】:
    RewriteCond %{REQUEST_URI} !/loader/$ [NC]
    RewriteCond %{REQUEST_URI} !/admin/$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([A-Za-z0-9-]+)/?$ /verload.php?name=$1 [R=302,L]
    

    【讨论】:

    猜你喜欢
    • 2015-10-01
    • 2021-06-30
    • 2016-09-18
    • 2021-04-10
    • 1970-01-01
    • 2013-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多