【发布时间】:2021-07-28 01:02:36
【问题描述】:
我有如下文件夹结构
-folder
--text
---index.php
我有一个如下所示的网址
https://example.com/folder/test/index.php?slug=slugname
我在 htaccess 中添加了以下代码来重写 URL。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?slug=$1 [QSA,L]
所以现在我的网址是
https://example.com/folder/test/slugname
我必须在我的 php 页面上获取 slugname,我尝试了 echo $_REQUEST['slug']; 和 echo $_GET['slug']; 但我得到了
slugname.php
我只想要我的slugname。
【问题讨论】:
-
@RavinderSingh13,请不要删除您的答案。清除缓存后就可以了
标签: apache .htaccess url mod-rewrite url-rewriting