Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to redirect all pages only to index.html using htaccess file and not redirect the image files

How to redirect all pages (pages only) to index.html using htaccess file and not redirect the image files. For some reason I am using this code and an image file on the index.html page isn't showing up.

RewriteEngine on RewriteCond %{REQUEST_URI} !^/index.html$ RewriteRule .* /index.html [L,R=302] 
like image 771
user2593041 Avatar asked Jul 17 '13 20:07

user2593041


People also ask

How do I redirect a domain to index HTML?

To redirect from an HTML page, use the META Tag. With this, use the http-equiv attribute to provide an HTTP header for the value of the content attribute. The value in the content is the number of seconds; you want the page to redirect after. Set the content attribute to 0, if you want it to load immediately.

What is RewriteEngine on htaccess?

htaccess rewrite rules can be used to direct requests for one subdirectory to a different location, such as an alternative subdirectory or even the domain root. In this example, requests to http://mydomain.com/folder1/ will be automatically redirected to http://mydomain.com/folder2/.

How to redirect all pages to another domain using htaccess?

How to redirect all pages to another domain using .htaccess: Set the nameservers of the old domain to somewhere you have cPanel hosting; Go into cPanel and add the old domain; Add a .htaccess file that 301 redirects all the internal pages to the new domain; Add a blank index.php for extra safety.

How do I redirect a page to another page in HTML?

Using Redirect in an .htaccess file enables you to redirect users from an old page to a new page without having to keep the old page. For example, if you use index.html as your index file and then later rename index.html to home.html , you could set up a redirect to send users from index.html to home.html .

How to redirect a single URL in WordPress?

Redirecting a single URL. Using Redirect in an .htaccess file enables you to redirect users from an old page to a new page without having to keep the old page. For example, if you use index.html as your index file and then later rename index.html to home.html, you could set up a redirect to send users from index.html to home.html. For example:

How do I redirect a request to a non-existing page?

If a visitor attempts to access a page that doesn't exist, they are presented with a 404 error. You can instead redirect any request to a non-existing page to your index.php file (or any index file) by adding the following code in your.htaccess:


1 Answers

Try this code :

RewriteEngine on RewriteCond %{REQUEST_URI} !^/index.html$ RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js)$ RewriteRule .* /index.html [L,R=302] 
like image 167
Lucas Willems Avatar answered Sep 26 '22 02:09

Lucas Willems