If someone tries to access these abbreviated page-types, then a 404 error: http://getcityweather.com/international/region/na.html http://getcityweather.com/international/ca/forecasts.html http://getcityweather.com/international/ca/al_forecasts.html http://getcityweather.com/international/ca/alberta_forecasts.html I had tried to use .htaccess file redirect # redirect all non-www traffic #RewriteCond %{HTTP_HOST} ^region/\?\?\.html$ #RewriteRule ^region/??\.html$ http://www.google.com [R=permanent,L] #RewriteRule ^region/([A-Za-z]{2})\.html$ http://www.google.com [R=permanent,L] or this below code Redirect 301 /region/af.html http://www.getcityweather.com/us/ PHP: Some one please let me know, whether I should do it through .htaccess way or is there anything in php like catching the url and redirecting them. Please help it is little urgent.
My knowledge of a rewrite rule is very limited, so I would Redirect 301 Maybe somebody in this forum will know how to do it with the rewrite rules.
Well your example was correct in your .htaccess file type Redirect 301 /region/na.html http://www.getcityweather.com/us/ Code (markup):
did you upload it to the root folder? and btw your htaccess is directing the wrong file if you look at mine i have added /region/na.html while you have done /region/af.html
Yes, it is in root folder cause there are other stuff, which are working fine. Actually, I am looking for both type of files na.html or af.html, in fact I like to have here any two characters of the file.html ab.html ac.html na.html sa.html All these type of files should go to the 404 error page. Thanks
Here is the other content of my file: Options +FollowSymLinks RewriteEngine On ###################### # Weather Directory ###################### Redirect 301 /region/af.html http://www.getcityweather.com/us/ #display regions RewriteRule ^forecasts\.html$ /international/dir_files/index.php?do=regions [L,S=1] #display countries in a region RewriteRule ^region/([A-Za-z][A-Za-z+]+)\.html$ /international/dir_files/index.php?do=countries&r=$1 [L,S=1] #display cities or states in a country RewriteRule ^([A-Za-z+]+)/forecasts\.html$ /international/dir_files/index.php?do=states&c=$1 [L,S=1] Code (markup):
Also, make sure you have the AllowOverride directive set up for the document root of your website. http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride
So, you want to redirect all /region/xx.html? RewriteRule ^region/(.*)\.html$ /us/ [NC,R,L] Code (markup):
why you are not using redirect 301, or redirect to 404 page using this meta header response <?php header("HTTP/1.0 404 Not Found"); ?>
I think this is the best solution for you. You can use it in your 404 page. So it may redirect all error link. http://www.osproseo.com/redirect-301-permanently-php/
Oh here is my code for this file, which is working like a charm. RewriteEngine On RewriteRule (^region/[A-Za-z]{2}\.html) - [F,L] ###/asdf [R,L] Code (markup): Once again thanks dpiers for your time for providing such valuable help. I want to set best answer but I don't want to others to discourage for their efforts.