Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.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 如何从htaccess中的某些重写规则中排除基本url?_Php_Regex_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Php 如何从htaccess中的某些重写规则中排除基本url?

Php 如何从htaccess中的某些重写规则中排除基本url?,php,regex,apache,.htaccess,mod-rewrite,Php,Regex,Apache,.htaccess,Mod Rewrite,大家好,我在.htaccess文件中有一个重写规则 RewriteRule ^([a-zA-Z0-9\-\_]+)?$ product.php?product=$1 [NC,L] 当我访问www.domain.com时,它将应用上述规则并重定向到product.php,当访问www.domain.com/index.php时,它工作正常。我做错了什么。感谢在您的正则表达式中删除?,它使整个模式成为可选模式,并将目录排除在此规则之外: RewriteCond %{REQUEST_FIL

大家好,我在.htaccess文件中有一个重写规则

RewriteRule  ^([a-zA-Z0-9\-\_]+)?$  product.php?product=$1    [NC,L]

当我访问www.domain.com时,它将应用上述规则并重定向到product.php,当访问www.domain.com/index.php时,它工作正常。我做错了什么。感谢

在您的正则表达式中删除
,它使整个模式成为可选模式,并将目录排除在此规则之外:

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

选项-索引
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$/your_project_folder_name/index.php/$1[L]
<IfModule mod_rewrite.c>
Options -Indexes

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /your_project_folder_name/index.php/$1 [L]
</IfModule>