我一直试图在我的网址中加入点数但是.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]更多推荐
发布评论