【问题标题】:beautify url from art.php?id=51 to art/51美化 url 从 art.php?id=51 到 art/51
【发布时间】:2021-06-02 16:52:43
【问题描述】:

想美化来自:
https://abuena.net/art.php?id=51的网址

https://abuena.net/art/51

这是我的尝试,没有成功,只是被忽略

RewriteEngine on
RewriteRule ^([a-zA-Z0-9_]+)$ /$1/ [R]
RewriteRule ^([a-zA-Z0-9_]+)/$ /art.php?id=$1

我的托管服务提供商说我的服务器不是 Apache,而是 LSWS - LiteSpeed WebServer - 这可能是我的语法问题。

有什么帮助吗?

【问题讨论】:

    标签: apache .htaccess mod-rewrite url-rewriting lightspeed


    【解决方案1】:

    请您尝试以下操作。考虑到您需要在浏览器中点击 https://abuena.net/art/51 之类的 URL。请确保在测试您的 URL 之前清除您的浏览器缓存。

    RewriteEngine ON
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]*)/(.*)/?$ $1.php?id=$2
    


    编辑:如果您在浏览器中点击https://abuena.net/art.php?id=51 之类的网址,请尝试关注一次。

    RewriteEngine ON
    RewriteCond %{REQUEST_URI} \s/([^.]*)\.php\?id=(\d+)\s [NC]
    RewriteRule ^ http://%{HTTP_HOST}/%1/%2 [R=301]
    RewriteRule ^([^/]*)/(.*)/?$ $1.php?id=$2 [L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多