Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我网站中的某些 url 给出 403 - 访问禁止错误。经过几个小时的研究,我发现有“。” (点)在我的网址中导致 403 错误。我想使用 .htaccess 将所有点替换为连字符
例如,我想更改以下网址
http://www.example.com/real-listings/0Bedrooms/commercial-land/TN/For-Sale/SELLING-FIVE-ACRE-LAND./Property.html
至
http://www.example.com/real-listings/0Bedrooms/commercial-land/TN/For-Sale/SELLING-FIVE-ACRE-LAND/Property.html
请提供建议并感谢您的帮助。
问候,
在文档根目录的 htaccess 文件中的任何规则之前添加这些规则:
RewriteEngine On RewriteRule ^(.*)\./([^/]+)(\.html?)$ /$1/$2$3 [L,R=301]
或者,如果您真的想用连字符替换那个点:
RewriteEngine On RewriteRule ^(.*)\./([^/]+)(\.html?)$ /$1-/$2$3 [L,R=301]