Welcome to WebmasterWorld Guest from 23.20.137.66

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

How to redirect .html?mkjkjd

     
6:23 am on Mar 26, 2012 (gmt 0)



Is possible to redirect urls which comes after .html?. I checked with few html websites inner page urls Ex: xyz.com/one.html.

If I add ? and any characters after .html
Ex: xyz.com/one.html?okujjk it's showing the same page, I like to give 404 error page for the second url xyz.com/one.html?okujjk, If possible means how to do?

Thank in advance
7:11 am on Mar 26, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Use a RewriteRule. Test QUERY_STRING with a preceding RewriteCond. If not blank, then rewrite the request to a non-existent path and that will generate a 404 error.

ErrorDocument 404 /error404.html


RewriteEngine On
#
RewriteCond %{QUERY_STRING} !.
RewriteRule .* /pathnotexist [L]


If there is any part of your site that does use query strings you'll need to exclude POST requests from being redirected for those paths and files.
7:24 am on Mar 26, 2012 (gmt 0)



Thank you g1smd :)
10:33 am on Mar 26, 2012 (gmt 0)



Can I use the same code for .php, .aspx, .asp as

ErrorDocument 404 /error404.php
ErrorDocument 404 /error404.aspx
ErrorDocument 404 /error404.asp
10:49 am on Mar 26, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



I don't understand the question.

You can have only one ErrorDocument directive for requests which generate a 404 status. This directive can point to any file you like.
11:02 am on Mar 26, 2012 (gmt 0)



My question was, Can I use the same code for php and asp websites?

Ex:
xyz.com/one.php?okujjk (php site)
xyz.com/one.asp?okujjk (asp site)
12:20 pm on Mar 26, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



As long as your site uses an Apache server you will be able to add that code to the site configuration files.

PHP will usually be yes.

ASP may not be, since ASP is found mostly on IIS - however recent versions of IIS support many htaccess-like features with similar syntax.
12:33 pm on Mar 26, 2012 (gmt 0)



Thank you so much g1smd :)
 

Featured Threads

Hot Threads This Week

Hot Threads This Month