.htaccess 如何使用htaccess规则重写到某个文件?

.htaccess 如何使用htaccess规则重写到某个文件?,.htaccess,.htaccess,我必须创建一个页面处理程序,它应该读取URL,并基于querystring执行特定操作 我需要使用.htaccess来做一些URL重写的事情,以这样的方式将所有内容指向进行处理的特定文件: https://example.com/folder/page1/ https://example.com/folder/page2/ 并且处理文件是https://example.com/folder/index.php 有没有办法做到这一点(可能是删除index.php部分)?试试这个,看看这是否有助于实

我必须创建一个页面处理程序,它应该读取URL,并基于querystring执行特定操作

我需要使用.htaccess来做一些URL重写的事情,以这样的方式将所有内容指向进行处理的特定文件:

https://example.com/folder/page1/

https://example.com/folder/page2/

并且处理文件是
https://example.com/folder/index.php


有没有办法做到这一点(可能是删除index.php部分)?

试试这个,看看这是否有助于实现您想要的目标

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /folder/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

重新启动发动机
重写库/文件夹/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则。index.php[L]
上面的代码是从WordPress获取的,当“RewriteBase/folder/”文件夹名称与您的文件夹一起更新时,应该可以使用。htaccess文件必须放在index.php文件所在的根/文件夹目录中