简体   繁体   English

htaccess mod url重写不起作用

[英]htaccess mod url rewrite not working

Trying to rewrite former urls to the latter. 尝试将前一个网址重写为后者。 Rewrite that doesn't work for some reason. 重写由于某种原因不起作用。 How to fix? 怎么修? Thanks. 谢谢。

www.example.com/example-example.html www.example.com/example-example.html

www.example.com/example-example/ www.example.com/example-example/

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([a-z]+-?[a-z]+)/$ /$1.html
Options +FollowSymLinks

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

Try this: 尝试这个:

RewriteRule ^([a-z-]+)/?$ $1.html

This will silently rewrite a user's request for /example-example/ to an actual file path /example-example.html. 这将以静默方式将用户对/ example-example /的请求重写为实际的文件路径/example-example.html。 No checking is performed to see whether the file path exists, and it will match any request which contains letters and hyphens. 不检查文件路径是否存在,并且它将匹配任何包含字母和连字符的请求。 If you need more specific constraints, let us know. 如果您需要更具体的限制,请告诉我们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM