Forum Moderators: phranque

Message Too Old, No Replies

Adding anything after ".php/abcd" :(

         

Swati Kanojia

6:35 am on Oct 5, 2012 (gmt 0)

10+ Year Member



Having the problem on normal static page with extension .php ...not having so much of dynamic functions as such
Problem is:
Adding a "/" and any characters after a properly formatted url on my site does not redirect the user to an error 404 page, rather it displays the page with broken css.
This only occurs on my .php pages, which account for 99% of my site.

Example:
www.mysite.com/page.php (works fine)
www.mysite.com/page.php (misspelled url redirects properly to 404, works fine)
www.mysite.com/page.php/iaddedthis (displays page with broken css but I would hope it resulted in a 404)

Do I need something add'l in my htaccess file to handle this ? Should I be calling this an invalid query?
GWT shows lots of errors and the site is of more than 500 pages in size so individual rewrites is not an option, nor could it be with all the odd ball url's coming up.

g1smd

6:45 am on Oct 5, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Turn the
AcceptPathInfo
option off if it is already on.

You could also block those requests with

RewriteRule ^([^/]+/)*[^/.]+\.php/.+ - [x]


Choose to replace [x] with [F] or [G] depending on what status code you want to return.

[edited by: g1smd at 7:47 am (utc) on Oct 5, 2012]

Swati Kanojia

6:59 am on Oct 5, 2012 (gmt 0)

10+ Year Member



@g1smd ..thanku sir but actly m not so experience in writing .htaccess....so shud i add the whole line u r giving to me? that Rewrite?

I have this in my .htaccess

rewritecond %{HTTP_HOST} ^mysite.com [nc]
rewriterule ^(.*)$ [mysite.com...] [r=301,nc]



ErrorDocument 404 [mysite.com...]

g1smd

7:46 am on Oct 5, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Replace [x] with [F] for 403 or [G] for 410.

# Block access
RewriteRule ^([^/]+/)*[^/.]+\.php/.+ - [x]


---

The NC flag is not needed.
Use example.com in this forum.
Add the L flag.
Escape literal periods in patterns.
Your redirect fails to redirect non-canonical requests with port number, etc.

# Redirect to www
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]


---

You must NOT use the domain name in the ErrorDocument directive.
If you do, it returns a 302 response, not a 404 response.
The Apache manual specifically warns about this.

# Errors
ErrorDocument 404 /404.php