简体   繁体   中英

Rewrite all html pages

I need clean urls (eg example.com/test) to redirect all requests without a file extension to html pages (so I can still call programmed pages without rewriting). I made a file that I hoped should do this, but it doesn't :/ Any ideas?

Here is my current .htaccess file:

RewriteEngine On    # Turn on the rewriting engine
RewriteRule  ^([^/.]+)/?$ $1.html [L]

Try this one. You have to set a RewriteCond(ition). Otherwise there's a infinite Loop...

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^/]+)$ $1.html 

尝试将此行放在顶部:

Options +FollowSymlinks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM