gpt4 book ai didi

regex - htaccess : generates error if dot(. ) 存在于查询字符串中

转载 作者:行者123 更新时间:2023-12-03 02:36:29 24 4
gpt4 key购买 nike

我编写的.htaccess文件如下:

Options +FollowSymLinks

RewriteEngine On

#open the product details page with the Product Number with PN prefix
RewriteRule ^((products/|product/|)PN[0-9-]+)/?$ product.php?pno=$1


#open the product search page for a particular category
RewriteRule ^((bat|ref|acc)[A-Za-z0-9-]+)/?$ search.php?cat=$1 [NC]

#open the product search page for a particular category
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9-_.,]+)/?$ search.php?search =$1 [NC]

RewriteRule !\.(html|php)$ - [S=4]
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5 [E=uscor:Yes]
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4 [E=uscor:Yes]
RewriteRule ^([^_]*)_([^_]*)_(.*)$ $1-$2-$3 [E=uscor:Yes]
RewriteRule ^([^_]*)_(.*)$ $1-$2 [E=uscor:Yes]
RewriteCond %{ENV:uscor} ^Yes$
  1. 它无法接受查询字符串值中是否有点(.)。现在,问题已经解决了,但是不能接受它之前的规则。

  2. 此外,如果给出了 URL“URL/products/PN123”或“URL/product/PN123”,我希望它正确重写“URL/product.php?pno=PN123”。请注意,如果使用正确的 CSS 正确给出“URL/PN123”,它可以正确重定向。 AND“URL/product/PN123”也可以检索数据,但无法正常显示 CSS。

最佳答案

这是您更正/更新的 .htaccess,但是如果写更多有关您的实际需求的信息会更好:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

#open the product details page with the Product Number with PN prefix
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((products/|product/|)PN[0-9-]+)/?$ product.php?pno=$1 [L,NC,QSA]

#open the product search page for a particular category
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((bat|ref|acc)[A-Za-z0-9-]+)/?$ search.php?cat=$1 [L,NC,QSA]

#open the product search page for a particular category
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9-_.,]+)/?$ search.php?search=$1 [L,NC,QSA]

RewriteRule !\.(html|php)$ - [S=4,NC]
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5 [E=uscor:Yes]
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4 [E=uscor:Yes]
RewriteRule ^([^_]*)_([^_]*)_(.*)$ $1-$2-$3 [E=uscor:Yes]
RewriteRule ^([^_]*)_(.*)$ $1-$2 [E=uscor:Yes]
RewriteCond %{ENV:uscor} ^Yes$

关于您的 css、js、图像文件:确保您的 css、js 等路径以斜杠 / 开头,而不是相对的斜杠。

关于regex - htaccess : generates error if dot(. ) 存在于查询字符串中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9312311/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com