我有一个包含以下行的.htaccess
文件
# ErrorDocument 404 /error/404.php
Options All -Indexes -MultiViews
RewriteEngine On
# Allow urls to not include the .php extension
RewriteCond %{REQUEST_URI}/$1.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php [L]
# Silent Redirect from any url ending with mcc-* to show.php?id=mcc-*
# This is the portion that isn't working
RewriteCond %{REQUEST_URI} (mcc-[\d]+)\.php$
RewriteCond %{REQUEST_URI}/$1.php -f [NC]
RewriteRule show.php?id=$1 [L]
我试图找到任何以模式(mcc-[\d]+)
结尾的网址,并将其重定向到show.php?id=%pattern%
,但试图访问与此模式匹配的页面只会返回404错误,因为没有文件mcc-*
。
1条答案
按热度按时间oxcyiej71#
请尝试使用下面的.htacess规则文件。此代码将在内部重写为show.php文件。请确保: