Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

URL Slash Problem

mysite/ (a PHP file) leads to "Internal Server Error"



12:18 am on Apr 14, 2008 (gmt 0)

5+ Year Member

Does anyone know why visiting my site at [mysite.com...] (which is the same as [mysite.com...] I'm using a Rewrite rule to make it extensionless) gives me an "Internal Server Error" message?

Visiting [mysite.com...] or [mysite.com...] gives no errors, though.

I'm thinking that the slash will make the server think that is a directory and that's why it's giving me the error message. I might be wrong, though. Hopefully you guys came across this before and can share some solutions. Thanks for reading this!


12:14 am on Apr 15, 2008 (gmt 0)

5+ Year Member

I could just ignore the mysite.php/ slash. But the problem is that I need that slash to create dynamic URLs.

For instance, I have [mysite.com...] (.php extension can be removed here, but you get the idea).

Then, I use a super variable $_SERVER['REQUEST_URI'] and the explode() function to split the URL in different parts. That way I can manipulate variables and work with my site using Clean URLs.


1:33 am on Apr 15, 2008 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

You might want to look at your server error log....



7:00 am on Apr 26, 2008 (gmt 0)

5+ Year Member

Hi jdMorgan,

I just checked my Apache Server Log just after trying to visit the .php file with a slash at the end and this is the Apache error I got:

mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.

Do you know what this means?


6:20 pm on May 8, 2008 (gmt 0)

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

Could you please post the ruleset you are using.

Apparently, there is some type of recursion causing an infinite loop on your rewrite.


6:53 pm on May 8, 2008 (gmt 0)

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

Before you redirect or rewrite, you need to exclude certain requests from causing the redirect or rewrite to be processed.

You'll need one or more RewriteCond statements to be added before the redirect or rewrite.


11:29 pm on May 8, 2008 (gmt 0)

5+ Year Member

Hi guys,

Apparently I've managed to get some progress here.
Now if I browse:

my-site.com/example.php/ or

It works just like:

my-site.com/example.php and

However, there is a problem. If there is a slash after the .php file, for some reason I can't see my CSS files being applied to the page. My page loses all the CSS styles. Very strange, I don't know why this happens. And also, if I visit:


It works perfectly. The file example.php is still being read. All I have now is "page1/page2/example_page_here", which I can use some PHP functions, such as EXPLODE and have each component of the URL in an Array so I can work with them. You get the idea right? Well the problem is that visiting:

my-site.com/example/page1/page2/example_page_here (no extension in example.php file)

...it doesn't work. I get a 404 File Not Found error. Apparently because it believes I'm trying to visit a directory, which is certainly not what I'm looking for. I'm pretty sure you guys know why I have "page1/page2/example_page_here" after the .php file. It's not really a directory, but more like a fake directory that I'll use to pass parameters to my page and work with those in my PHP code.

This is the code I'm using in my .htaccess file:

## Converts test.php to test
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
##RewriteRule ^(.*)$ $1.php
RewriteRule ^([^/]+)/?$ $1.php [L]

Do you guys know why I'm having this problem? Is there a rule I could write in my .htaccess file to fix this?

Thanks a lot, I really appreciate your help!


Featured Threads

Hot Threads This Week

Hot Threads This Month