大多数用于重定向和删除文件扩展名或用于动态 url。
问题是我无法获得一个简单的静态 url 来重命名
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^fileThathasalongname file.html
我目前拥有的'mysite.co.uk/fileThathasalongname.html'
我想要的是'mysite.co.uk/file/' while file = file.html
使用:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteRule ^FileIWantToChange.html FriendlyNamed.html
使用这个给了我多个选择的错误
+++++++++++++++++++编辑+++++++++++++++++++++++++++++
以为我会添加我的最终版本供人们查看,它可能会有所帮助,下面的答案是正确的。
Options +FollowSymLinks -MultiViews
DirectorySlash Off
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME}/ -d
RewriteCond %{SCRIPT_FILENAME}.html !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.+)\.html$ /$1 [R=301,L]
RewriteRule ^FriendlyNamed.html FileIWantToChange.html [L]
RewriteCond %{SCRIPT_FILENAME}.html -f
RewriteRule [^/]$ %{REQUEST_URI}.html [QSA,L]
RewriteCond %{HTTP_HOST} ^www.mysire.co.uk [NC]
RewriteRule ^(.*)$ http://mysite.co.uk/$1 [L,R=301]
一切都很有魅力!