在opencart中.htaccess中的url之间不允许有点(Dot not allowed between the url in .htaccess in opencart)

编程入门 行业动态 更新时间:2024-10-28 04:29:41
在opencart中.htaccess中的url之间不允许有点(Dot not allowed between the url in .htaccess in opencart)

我一直试图在我的网址中加入点数但是.htaccess RewriteRule并没有帮助我这样做。 我一直在使用以下表达式

RewriteRule ^user/(\w+)/([-a-zA-Z0-9_\.]) index.php?id=$1&route=$2 [L,QSA]

虽然这允许我在url的末尾添加一个点,它不允许我在url之间这样做。

例如,如果我使用http://localhost/opencart/user/vendor_name.

它不会给出错误,但如果我使用http://localhost/opencart/user/vendor.name

它给出了找不到页面的错误。

任何人都可以给我一个表达,让我这样做。

I have been trying to include dot in my url but .htaccess RewriteRule is not helping me to do so. I have been using the following expression

RewriteRule ^user/(\w+)/([-a-zA-Z0-9_\.]) index.php?id=$1&route=$2 [L,QSA]

while this allows me to add a dot at the end of url it doesnt allow me to do so in between the url.

for eg if i use http://localhost/opencart/user/vendor_name.

it doesnot give an error but if i use http://localhost/opencart/user/vendor.name

it gives an error of page not found.

Can anyone give me an expression that will allow me to do so.

最满意答案

因为你的正则表达式是错误的。 斜线后, [-a-zA-Z0-9_\.]仅匹配单个点。

试试这条规则

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^user/[-\w.]+)/([-\w.]+)/?$ index.php?id=$1&route=$2 [L,QSA]

Because your regex is wrong. [-a-zA-Z0-9_\.] will match only single dot after slash.

Try this rule

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^user/[-\w.]+)/([-\w.]+)/?$ index.php?id=$1&route=$2 [L,QSA]

更多推荐

本文发布于:2023-08-01 13:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1359295.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不允许   htaccess   opencart   url   allowed

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!