【问题标题】:Replacing URLs with .htaccess or something else?用 .htaccess 或其他东西替换 URL?
【发布时间】:2013-08-27 18:13:47
【问题描述】:

我看到一些网站用其他内容替换了原来的 URL。示例:他们不使用http://url.com/profile/index.php?username=USERNAME,而是使用http://url.com/profile/USERNAME

我该怎么做?

【问题讨论】:

标签: php regex apache .htaccess mod-rewrite


【解决方案1】:

通过httpd.conf启用mod_rewrite和.htaccess,然后把这段代码放到你.htaccessDOCUMENT_ROOT目录下:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^(profile)/([^/.]+)/?$ /$1/index.php?username=$2 [L,QSA,NC]

【讨论】:

    猜你喜欢
    • 2016-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-20
    • 1970-01-01
    • 2018-10-28
    • 2011-04-13
    • 1970-01-01
    相关资源
    最近更新 更多