homepage Welcome to WebmasterWorld Guest from 54.198.94.76
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
How to redirect .html?mkjkjd
sugi




msg:4433349
 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

 

g1smd




msg:4433364
 7:11 am on Mar 26, 2012 (gmt 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.

sugi




msg:4433383
 7:24 am on Mar 26, 2012 (gmt 0)

Thank you g1smd :)

sugi




msg:4433471
 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

g1smd




msg:4433475
 10:49 am on Mar 26, 2012 (gmt 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.

sugi




msg:4433477
 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)

g1smd




msg:4433486
 12:20 pm on Mar 26, 2012 (gmt 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.

sugi




msg:4433488
 12:33 pm on Mar 26, 2012 (gmt 0)

Thank you so much g1smd :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved