dongshi3361 2017-05-29 19:08
浏览 16

如何在htaccess中允许点(。)?

This is my htaccess file, and for some reason this rule: RewriteRule ^profile/([^/]+)$ ./profile.php?name=$1 doesn't allow dots in the link. It allows any other symbol, but not the dot (.). How can I fix this?

Options -MultiViews -Indexes
RewriteEngine On

RewriteCond %{HTTP:VIA}                 !^$ [OR]
RewriteCond %{HTTP:FORWARDED}           !^$ [OR]
RewriteCond %{HTTP:USERAGENT_VIA}       !^$ [OR]
RewriteCond %{HTTP:X_FORWARDED_FOR}     !^$ [OR]
RewriteCond %{HTTP:PROXY_CONNECTION}    !^$ [OR]
RewriteCond %{HTTP:XPROXY_CONNECTION}   !^$ [OR]
RewriteCond %{HTTP:HTTP_PC_REMOTE_ADDR} !^$ [OR]
RewriteCond %{HTTP:HTTP_CLIENT_IP}      !^$
RewriteRule ^(.*)$ - [F]

DirectorySlash On

ErrorDocument 404 /404.php
ErrorDocument 403 /404.php
ErrorDocument 502 /brb.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} (.+)/$

RewriteCond %{THE_REQUEST} /profile\?name= [NC]
RewriteRule ^ - [L]


RewriteRule ^profile/([^/]+)$ ./profile.php?name=$1 


RewriteCond %{ENV:REDIRECT_STATUS} ^$

RewriteRule ^([^/.]+)\.php - [F,L,R=404]
RewriteRule ^([^/.]+)$ $1.php [L]

On my website, users can register with any name (thus any character). But let's say I put my fictional name to be "Mr.BoogieMan.", the link to my profile should be www.website.com/profile/Mr.BoogieMan. But since the dot is in my name, htaccess won't let that go through.

  • 写回答

1条回答 默认 最新

  • dtpt75860 2017-05-29 19:11
    关注

    Dot (.) is a special character in regular expressions meaning "any character". To use a dot (.) you must escape it like so:

    \.
    
    评论

报告相同问题?

悬赏问题

  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测