建议立即进行删除我加入什么行删除HTML和PHP扩展从我的网站?
What lines shoul I add to remove both html and php extensions from my site ?
我用这个为HTML:
RewriteEngine on
RewriteBase /
RewriteCond %{http://jobler.ro/} !(.[^./]+)$
RewriteCond %{REQUEST_fileNAME} !-d
RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule (.*) /$1.html [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /([^.]+).html HTTP
RewriteRule ^([^.]+).html$ http://jobler.ro/$1 [R=301,L]
但我需要从同一个域中的两个文件类型的扩展名。
but I need for both file type extensions from the same domain.
您将要测试是否与的.html
或的.php文件
的存在,然后重定向到这样的文件,如果如此。
You would want to test whether the file with .html
or .php
exists, and then redirect to such file if so.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [L]
RewriteCond %{REQUEST_URI} .((html)|(php))$
RewriteRule ^(.*).([^.]+)$ $1 [R,L]