I want to change/rename urls in my website. For now I'm just removing .html in url like this:
ErrorDocument 404 /errorpage.html
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]
I want to change urls. For example: index.html -> home, aboutus.html -> about-us etc. I tried changing but I got server client error 500:
ErrorDocument 404 /errorpage.html
RewriteEngine on
RewriteRule ^index\.html /home [NC,L]
RewriteRule ^aboutus\.html /about-us [NC,L]
It's not clear why you would get a 500 error here, unless you had combined these rules with the former rule that handled
.htmlextensionless URLs (this would have caused a rewrite-loop, ie. 500 error).However, the arguments you are passing to the
RewriteRuledirectives are the wrong way round. You should be rewriting from/hometo/index.htmlinstead. The first argument matches the requested URL. The second argument (the substitution string) represents the URL (or file-path) you are rewriting to.Your directives should be like this instead:
The slash prefix on the substitution string (second argument) is not required.
You should be linking to URLs of the form
/homeand/about-usin your HTML source and mod_rewrite internally rewrites these requests to the corresponding file that actually handles the request.