2

I have a url "www.example.com/abc/abc.php" If I change it to "www.example.com/abc/abc.php/asdasd", some kind of infinite loop starts and the server's memory peaks to 100%.

I have heard that there's some way by .htaccess by which I can redirect any "abc.php/asdasd" to "abc.php" only. Please help how, as I am not able to understand it from other examples mentioned on net.

NOTE : I dont want this "/" to be removed if it is put at the end of directories though.

soundswaste
  • 2,964
  • 3
  • 23
  • 40

2 Answers2

2

This would redirect one URL to another:

Redirect 301 /abc.php/adssd http://www.example.com/abc.php

However, this will only handle this one example. You should post your full .htaccess file so we can see what's really going on

Paul Dessert
  • 6,363
  • 8
  • 47
  • 74
  • I dont have an htaccess yet. I want all the files in my server that end with a ".php" to stay that way even after adding a "/" or "/abcd" after php . – soundswaste Aug 20 '12 at 23:15
  • 1
    You can read this for more detailed info. http://serverfault.com/questions/175517/apache-htaccess-remove-everything-after-php However, I wouldn't recommend this. You shouldn't be in an infinite loop when you enter a random URL. You should look at your code and see if there is another problem going on – Paul Dessert Aug 20 '12 at 23:18
0

I was able to achieve what I wanted by the following htaccess code :

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.php/(.*) $1.php [F]
</IfModule>

This may not be perfect, but gets the job done. Now anything after the text 'abc.php' results in a page-not-found. Works for cases like :

www.website.com/abc.php/

www.website.com/abc.php/asd

www.website.com/abc.phpasd

www.website.com/abc.php?

etc.

soundswaste
  • 2,964
  • 3
  • 23
  • 40
  • Since your .htaccess script gives a 404 error for `www.website.com/abc.php?`, it could be a problem if you ever want to [use Google Analytics URL builder](http://support.google.com/analytics/answer/1033867?hl=en) for custom campaigns – Baumr Apr 24 '13 at 09:08