【发布时间】:2020-11-06 15:56:55
【问题描述】:
在对 stackoverflow 进行了大量研究后,我无法弄清楚。 我有一个结构如下的网站
index.php
contact.php
about.html
forum(dir)
- index.php
- thread.php
我希望我的 htaccess 做什么
- 删除.php & .html 扩展名,例如:当您访问联系页面时,url 应该是
www.domain.com/contact/&www.domain.com/about/ - 当用户访问论坛时,url应该是
www.domain.com/forum/thread/10004000/而不是www.domain.com/forum/thread?id=10004000
我不知道如何弄清楚。我能够删除扩展,但在/“正斜杠”部分失败
这是我的 .htaccess 部分
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
【问题讨论】:
-
立即尝试,它在我的网站上运行shantunparmar.in,您只需替换为您的文件或文件夹名称
-
它给出了 403 错误。
-
你能给我看看你更新的吗
-
我再次更新了支票
-
给我一点时间,我正在尝试与我的域相同
标签: php .htaccess subdirectory clean-urls