Reputation: 1429
htaccess redirection and would like to redirect all visitors on (domain.com, domain.com/,domain.com/index.php ) to www.domain.com/index.php#block_1 . below is my rules in .htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
RewriteRule index\.php index.php#block_1 [NE]
i keep getting error 500, Some one point what im doing wrong
Upvotes: 0
Views: 284
Reputation: 1041
To escape the "#", try \%23 with an [NE,L] flag on the rule.
RewriteRule index\.php index.php\%23block_1 [NE,L]
Upvotes: 0
Reputation: 1889
I believe the error is because you're specifying an internal (Non-HTTP) redirect, which happens to send apache into a redirect loop.
Try:
RewriteRule index\.php index.php#block_1 [NE,R]
Because browsers never send the anchor part of the URL string to the server, you cannot test for it, so this will likely cause an infinite HTTP redirect loop for the client.
You will likely have to redirect to a second page, like this.
RewriteRule index\.php otherpage.php#block_1 [NE,R]
The mod_rewrite documentation explains it all.
Upvotes: 3