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/
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. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.