I need help to redirect these links to 404 error

by 4 replies
5
If someone tries to access these abbreviated page-types, then a 404 error:

http://getcityweather.com/international/region/na.html
http://getcityweather.com/internatio...forecasts.html
http://getcityweather.com/internatio...forecasts.html
http://getcityweather.com/internatio...forecasts.html

I had tried to use .htaccess file redirect

[code]
# 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/

[\code]

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.
#programming #404 #error #links #redirect
  • server {
    listen 80;
    server_name _;
    root /var/www/vhosts/$host/httpdocs/;
    error_page 404 /;
    location / {
    try_files $uri $uri/ /index.php;
    }
    location ~ \.php$ {
    try_files $uri =404;
    include fastcgi_params;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_script_name;
    #fastcgi_pass php;
    fastcgi_pass 127.0.0.1:9000;
    }
    location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
    expires max;
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    }
    # this prevents hidden files (beginning with a period) from being served
    location ~ /\. { access_log off; log_not_found off; deny all; }
    }
  • lol! is this is a php script or httaccess file? sorry bro, would you please put some light on it.

    Little description will be appreciated. I am looking for some html links not the php ones.

    Any how thanks a lot for stop by and put that great code here.
  • Thanks guys for your response, I had sort out this thing by Mr. google.

    Oh here is my code for this file, which is working like a charm.

    Code:
    RewriteEngine On
     
    RewriteRule (^region/[A-Za-z]{2}.html) - [F,L] ###/asdf [R,L]

    Once again thanks warriors 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.
  • I'm sending you a PM now.

    Theres something wrong with the .html file you have set up.

    WILL -

Next Topics on Trending Feed