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]