为什么URL参数不起作用重写URL htaccess?

我正在尝试获取带有重写URL的博客详细信息页面

像这样->> www.sitename.com/blog/test-post

我的代码是

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

我的问题是,它将进入详细信息页面,但进入博客列表页面

www.sitename.com/blog/

还重定向到博客详细信息页面。我如何避免这种情况。我也尝试过用这样的数字代码

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

带有数字参数的url可以正常工作,但是字母不起作用。该如何解决?

laonongding 回答:为什么URL参数不起作用重写URL htaccess?

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

<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>
本文链接:https://www.f2er.com/3112472.html

大家都在问