Redirect 301 /index.html http://sites.com/ RewriteEngine On RewriteRule ^([a-zA-Z0-9_-]+)$ fffolder/$1.php RewriteRule ^([a-zA-Z0-9_-]+)/$ fffolder/$1.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d #If file not foun redirect to index RewriteRule .* index.html [PT] #Redirect direct access to all php files in fffolder RewriteRule ^(.*)\.php$ index.html [R=301,L]
1和2正在工作但3不工作,如何写出正确的语法?
答案 0 :(得分:1)
您可以使用:
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.html [NC]
RewriteRule ^(.*?)index\.html$ /$1 [L,R=301,NC]
#Redirect direct access to all php files in fffolder
RewriteCond %{THE_REQUEST} /.+\.php [NC]
RewriteRule \.php$ /index.html [R=301,L,NC]
RewriteRule ^([\w-]+)/?$ fffolder/$1.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#If file not foun redirect to index
RewriteRule ^ index.html [L]