我应该添加什么行来从我的网站中删除.html
和.php
扩展名?
我只是使用这个.html
部分:
RewriteEngine on RewriteBase / RewriteCond %{http://jobler.ro/} !(\.[^./]+)$ RewriteCond %{REQUEST_fileNAME} !-d RewriteCond %{REQUEST_fileNAME} !-f RewriteRule (.*) /$1.html [L] RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /([^.]+)\.html\ HTTP RewriteRule ^([^.]+)\.html$ http://jobler.ro/$1 [R=301,L]
但我需要两个文件types的扩展名从相同的域隐藏。
我知道它迟到回答,但我给它,因为它可以是有用的人:)
#Remove php extension RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php #Remove html extension RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(.*)$ $1.html
这将从您的文件中删除PHP和HTML扩展名,并完美地工作。
你会想测试是否存在.html
或.php
,然后重定向到这样的文件。
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]