Forum Moderators: phranque
www.website.com/about-us.html
www.website.com/services.html
www.website.com/another-service-option.html
www.website.com/services/service2.html
Rewrite to these type with htaccess:
www.website.com/about-us/
www.website.com/services/
www.website.com/another-service-option/
www.website.com/services/service2/
I do not want the folders to exist. I just want it to look like they really do exist with url rewriting. can anyone help me with this?
Please see our Apache Forum Charter [webmasterworld.com] for more information.
Thanks,
Jim
mod_rewrite cannot "change" a URL; Only the links on your pages define the URL.
What mod_rewrite *can* do is to connect your new "about-us/" URL to the existing "about-us.html" file on your server.
It's a two-step process: You must change the links on your pages to the extensionless format, and then add code to .htaccess to connect those new URLs to your server files. After that is done, there's an optional third step, best not addressed until the first two are working.
The cited thread goes into some detail about this.
Jim
# Rewrite extensionless non-blank URL requests to add ".html" if corresponding ".html" file exists:
# If no file extension or trailing slash on requested URL-path
RewriteCond $1 !(\.[^./]+)$
# And if requested URL-path plus ".html" resolves to an existing file
RewriteCond %{REQUEST_FILENAME}.html -f
# Then rewrite to add .html extension and serve that file
RewriteRule ^(.+)$ /$1.html [L]
Jim