i need to create a redirect to a non existing page. here is my code and the site is on shared hosting <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule ^index2\.php#!(.*)$ /index2\.php/$1 [R=301,L] </IfModule> this would be my url ttp://sub.domain.com/index2.php#!time/ i would like to redirect avery request with "#!string" to new url (same page) - ttp://sub.domain.com/index2.php/time/ i know that the code above needs RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d to be added but it doesnt even makes the redirect to 404. the url doesnt change. thanks
I am not to sure you will actually need a RewriteCond. If you just want it to redirect it should be fairly simple. I am going to test a few things and get back to you and see.
I would think you should be able to do it simply similar to this example I found. RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ get_product_by_name.php?category_name=$1&product_name=$2 [NC,L] Code (markup): The pattern in the first part, then where to send it in the second part and of course with a 301 at the end. Or I suppose a RewriteCond can work as well with something like this example. RewriteCond %{HTTP_HOST} old_domain\.com [NC] RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301] Code (markup): If you are getting 404 errors, something is screwy with the way it was written in the htaccess file. I know its not the best help, but keeping it as simple as possible is probably the best way to go about it.
I may be missing something small.... did you try both of the ways below? I think the simplicity is on the right track though and may just have to wait until someone else takes a look to clean it up. RewriteRule ^index2\.php#!(.*) /$1 [R=301,L] RewriteRule ^index2\.php#!(.*)$ /$1 [R=301,L] Code (markup):