homepage Welcome to WebmasterWorld Guest from 54.237.134.62
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
URL Slash Problem
mysite/ (a PHP file) leads to "Internal Server Error"
cosmoyoda




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

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!

 

cosmoyoda




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

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.

jdMorgan




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

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

Jim

cosmoyoda




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

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?

TheMadScientist




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

Could you please post the ruleset you are using.

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

g1smd




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

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.

cosmoyoda




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

Hi guys,

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

my-site.com/example.php/ or
my-site.com/example/

It works just like:

my-site.com/example.php and
my-site.com/example

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:

my-site.com/example.php/page1/page2/example_page_here

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!

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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved