skip to Main Content

I have a website, I need to display ONLY the home page instead of an actual URL being request (website is work in progress).

Any urls within that domain should be rewritten to index.html and only index.html should be visible in the entire website.

How to write the rules in my current script?
Notes: I am not interested on the SEO impact.

RewriteEngine on

# SECURITY : Directory Listing denied
options -indexes

# UTILITY : Redirect WebMail
redirect permanent /email http://www.example.com:2095/3rdparty/roundcube/index.php?



RewriteCond %{HTTP_HOST} ^example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^/?$ "http://www.example.com/" [R=301,L]

3

Answers


  1. Chosen as BEST ANSWER

    I was able to solve my problem with the following code

    RewriteCond %{REQUEST_URI} !^/index.html$
    RewriteCond %{REQUEST_URI} !.(gif|jpe?g|png|css|js|swf)$
    RewriteRule .* /index.html [L,R=302]
    

  2. RewriteEngine on
    RewriteRule ^.+$ /index.html [L]

    Try this

    Login or Signup to reply.
  3. You can have your .htaccess like this:

    # SECURITY : Directory Listing denied
    options -indexes
    # by default load index.html 
    DirectoryIndex index.html
    
    RewriteEngine on
    
    # UTILITY : Redirect WebMail
    RewriteRule ^email/?$ http://%{HTTP_HOST}:2095/3rdparty/roundcube/index.php? [L,R=301]
    
    RewriteRule !^(index.html|.+?.(gif|jpe?g|png|css|js|swf|ico))?$ / [NC,L,R=302]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search