Question

How to create .htaccess file that redirect short links into html files? Eg.

    RewriteEngine On
    RewriteRule ^/start$ http://www.%{HTTP_HOST}/index.html [L]

The above rule gives me a 404 error. I have my index.html in the main folder.

Was it helpful?

Solution

That is because of leading slash. Try this:

RewriteEngine On
RewriteRule ^start/?$ /index.html [L]

.htaccess is per directory directive and Apache strips the current directory path (thus leading slash) from RewriteRule URI pattern.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top