Forum Moderators: phranque
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!
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.
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?
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!