Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 查询参数的子文件夹| mod_rewrite中的附加.htaccess_Php_Regex_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Php 查询参数的子文件夹| mod_rewrite中的附加.htaccess

Php 查询参数的子文件夹| mod_rewrite中的附加.htaccess,php,regex,apache,.htaccess,mod-rewrite,Php,Regex,Apache,.htaccess,Mod Rewrite,我有一点修改的问题,真的需要一些帮助 我需要在我域上的项目的子文件夹中有第二个.htaccess文件 项目的URL如下所示: https://example.com/project-name/ 现在我有了一个查询参数,我想用mod_rewrite为其创建一个漂亮的URL 包含参数的URL如下所示: https://example.com/project-name/index.php?preset=nameofapreset 我希望它是: https://example.com/project

我有一点修改的问题,真的需要一些帮助

我需要在我域上的项目的子文件夹中有第二个.htaccess文件

项目的URL如下所示:

https://example.com/project-name/
现在我有了一个查询参数,我想用mod_rewrite为其创建一个漂亮的URL

包含参数的URL如下所示:

https://example.com/project-name/index.php?preset=nameofapreset
我希望它是:

https://example.com/project-name/nameofapreset
重要的一点是:修改只适用于当前文件夹没有关于当前路径的任何信息,因为我也需要在其他文件夹中使用该文件

这是我认为应该起作用的(因为我在另一个项目中使用了类似的重写规则):

但事实并非如此。我所有的尝试都失败了

你知道我该怎么做吗


谢谢

您可以在
/project name/.htaccess
中使用此规则:

RewriteEngine On

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

很有效,非常感谢!!即使没有QSA参数。
RewriteEngine On

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