htaccess-如何只获取域名和url中的一个变量



我的远程服务器是LiteSpeed,而不是Appache
不确定htaccess代码是否相同

原始url-example.com/index.php?c=kb

.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^home/(.*)$ /index.php?c=$1 [L]

<base href="/">

结果-example.com/home/kb-工作良好

现在我想删除home-以获得-example.com/kb

RewriteRule . /index.php [L]  

页面在那里,但缺少cssjs
似乎<base href="/">有问题
有什么帮助吗?

查看-example.com/kb。服务器上-example.com/index.php?c=kb

您可以尝试以上方案的此代码:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([w-]+)/?$ index.php?c=$1 [L,QSA]

参考文献:

  • Apache mod_rewrite简介
  • Apache mod_rewrite技术详细信息
  • .htaccess提示和技巧

最新更新