Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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 当存在同名页面时,mod_重写不起作用_Php_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Php 当存在同名页面时,mod_重写不起作用

Php 当存在同名页面时,mod_重写不起作用,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我有一个页面shirts.php,其中列出了所有衬衫,然后有一个页面product.php?id=X,其中显示了各个产品的信息 如果我这样写规则: RewriteRule ^mens_shirts/([0-9]+)$ product.php?id=$1 [L] 输入url为mens_shirts/22它使用干净的url正确显示产品页面 但是,如果我编写如下规则: RewriteRule ^shirts/([0-9]+)$ product.php?id=$1 [L] 输入url是/shirts

我有一个页面shirts.php,其中列出了所有衬衫,然后有一个页面product.php?id=X,其中显示了各个产品的信息

如果我这样写规则:

RewriteRule ^mens_shirts/([0-9]+)$ product.php?id=$1 [L]
输入url为
mens_shirts/22
它使用干净的url正确显示产品页面

但是,如果我编写如下规则:

RewriteRule ^shirts/([0-9]+)$ product.php?id=$1 [L]
输入url是
/shirts/20
,它不显示产品页面,而是显示shirts.php

试试看:

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

RewriteRule ^shirts/([0-9]+)$ product.php?id=$1 [NC,L]


FollowSymLinks
-服务器将遵循此目录中的符号链接。

太好了!就我个人而言,+FollowSymLinks和-MultiViews到底在做什么?很有趣,谢谢!我会尽快接受答案me@General_Twyckenham如果这个答案解决了您的问题,请不要忘记标记它,谢谢。