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.

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

2 Comments

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 .
You can read this for more detailed info. serverfault.com/questions/175517/… 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
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.

1 Comment

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 for custom campaigns

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.