Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.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
Regex 为什么URL参数不起作用重写URL访问?_Regex_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Regex 为什么URL参数不起作用重写URL访问?

Regex 为什么URL参数不起作用重写URL访问?,regex,apache,.htaccess,mod-rewrite,Regex,Apache,.htaccess,Mod Rewrite,我正试图获得博客详细信息页面与重写网址 像这样->> 我的代码是 <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^/?([a-z]+) details.php [L] </IfModule> 重新启动发动机 重写规则^/?([a-z]+)details.php[L] 我的问题是,它来自详细信息页面,但博客列表页面 也重定向到博客详细信息页面。我怎样才能避免这种情况。我也试过这样的数字代码 <If

我正试图获得博客详细信息页面与重写网址

像这样->>

我的代码是

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/?([a-z]+) details.php [L]
</IfModule>

重新启动发动机
重写规则^/?([a-z]+)details.php[L]
我的问题是,它来自详细信息页面,但博客列表页面

也重定向到博客详细信息页面。我怎样才能避免这种情况。我也试过这样的数字代码

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^/?([0-9]+) details.php [L]
</IfModule>

重新启动发动机
重写规则^/?([0-9]+)details.php[L]

带有number参数的url工作正常,但字母不工作。如何解决此问题?

您需要从规则中跳过文件和目录:

<IfModule mod_rewrite.c>
RewriteEngine on

# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . details.php [L]

</IfModule>

重新启动发动机
#如果请求不是针对有效目录的
重写cond%{REQUEST_FILENAME}-D
#如果请求不是针对有效文件的
重写cond%{REQUEST_FILENAME}-F
重写规则。details.php[L]