Welcome to WebmasterWorld Guest from 54.167.46.29

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

How to redirect .html?mkjkjd

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

New User

joined:Mar 26, 2012
posts: 5
votes: 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)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 0


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)

New User

joined:Mar 26, 2012
posts: 5
votes: 0


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

New User

joined:Mar 26, 2012
posts: 5
votes: 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)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 0


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)

New User

joined:Mar 26, 2012
posts: 5
votes: 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)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 0


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)

New User

joined:Mar 26, 2012
posts: 5
votes: 0


Thank you so much g1smd :)
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members