2015-04-01 153 views
0

道歉,但我對URL重寫很新。我已經設法使重寫工作在傳統意義上,但不能強迫它有一個尾隨斜線。.htaccess強制刪除重寫

下面是代碼:

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.html -f 
RewriteRule ^(.*)$ /$1.html [L,QSA] 

回答

0

你可以試試:

RewriteEngine On 
RewriteBase/

# add a trailing slash for non-files 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301,NE] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.html -f 
RewriteRule ^(.*)/?$ $1.html [L]