400

How redirect specific url using htaccess rewrite rules

Question:

How can I redirect this URL:

http://domain.com/index.html#!

To this One:

http://domain.com/

Using htaccess rewrite rules?

Answer1:

For /index.html to / you need:

RewriteEngine On RewriteCond %{THE_REQUEST} \ /+index\.html RewriteRule ^ / [R=301,L]

That could incidentally fix the #! part of your URL as well, but that part of the URL is called a <strong>fragment</strong>, and is added there by something that's on the client side, it stays on the client side, and it is <em>never</em> transmitted to the server. So no htaccess or server side anything is going to know it's even there. If you want to remove it, you need to figure out what script is adding it there and remove the script. If you simply add javacsript to remove it, that other script may inadvertently add it back.

if (location.href.indexOf("#") > -1) { location.assign(location.href.replace(/\/?#/, "/")); }

Recommend

  • Redirecting error using .htaccess
  • Redirect all to base domain
  • .htaccess includes old part of url
  • What exactly happened with the indexing operation?
  • Having issue deserializing string with XSD
  • htaccess php_value auto_prepend_file gives me internal 500 error
  • dyanmic url not rewriting ht access
  • Creating a grid of images with jQuery
  • Redirect only with specific domain
  • .htaccess mod_rewrite Unknown number of Variables of a GET form
  • Carriage return required when printing to the console in Windows?
  • Using a ListFragment with a SimpleCursorAdapter with the Holder Pattern
  • Htaccess Public Folder Rewrite Rule
  • Navigation drawer is always inflated
  • Are there any fluent WPF projects? [closed]
  • How can I detect errors in an HTML document fragment with Ruby?
  • Running a Service from ASyncTask or Thread?
  • Back press fragments issue in android
  • Help with mod_rewrite
  • Image map in Flex
  • ASP.NET MVC Application won't update some controllers
  • Adding elements to a huge XML file
  • What's the purpose of QString?
  • How can I speed up CURL tasks?
  • How to define and use opencv mat of user type
  • Refering to the class itself from within a class mehod in Objective C
  • Nant, Vault & Windows Integrated Authentication
  • Regex thinks I'm nesting, but I'm not
  • What is Eclipse's Declaration View used for?
  • Bug in WPF DataGrid
  • TFS: Get latest causes slow project reloading
  • Javascript Callbacks with Object constructor
  • Cassandra Data Model
  • htaccess rewriting URLs with multiple forward slashes
  • How to make Safari send if-modified-since header?
  • Jquery - Jquery Wysiwyg return html as a string
  • SVN: Merging two branches together
  • Getting Messege Twice Using IMvxMessenger
  • Append folder name and increment by 1 using batch script
  • Python/Django TangoWithDjango Models and Databases