index.php

How can i remove index.php?
I must write everywhere index.php/somtehing to load a page

Tips And Tricks

The link below will take you to the Tips and Tricks section with the answer.

http://zoopframework.com/forum/tips-and-tricks/htaccess-rewrite-rule-for...

jmorant@cloud9l... 01 Dec 2008

I have already try it

It`s not working

some81 08 Dec 2008

How Are You Implementing?

Are you implementing the rewrite rule via a .htaccess file or directly via an Apache configuration file? Could you post the section where you are attempting to use the rule so I can see what might be going wrong.

jmorant@cloud9l... 08 Dec 2008

Hi

I copied and pasted tha code in .htaccess and I changed the paths

# .htaccess file for Zoop applications
# Applies rewrite rules for canonical domain names and sexier URI query strings.

RewriteEngine on

# Canonical domain name rewrite
# Modify the next two lines to redirect to a canonical domain name.
#RewriteCond %{HTTP_HOST} !^test.surnica.com\.com$ [NC]
#RewriteRule ^(.*)$ http://test.surnica.com/$1 [L,R=301]

# Modify the RewriteBase if you are using Zoop in a
# subdirectory and rewrite rules don't work.
RewriteBase /

# Rewrite URLs to the form 'index.php/x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

some81 08 Dec 2008

As a test

Add the following line to your htaccess file, just after RewriteEngine on:

RewriteRule .* http://google.com/ [L,R=301]

Visit your site and see if you're redirected to Google instead.

I'm guessing that your server has .htaccess overrides disabled. If this is the case, you'll have to either enable them, or edit the vhost definition in your apache config to add the mod_rewrite handling there.

A less likely, and prob'ly lamer, scenario is that you don't have mod_rewrite on your server. To test for that, remove the lines that say <IfModule mod_rewrite.c> and </IfModule>... If your server spits out a 500 error and starts writing nasty messages in your error log, you're going to have to figure out how to install/enable mod_rewrite.

justin 12 Dec 2008

Same here

Hello, this is my first posting here on zoopframework.com.

I also have to make a website with URLs without "index.php" in them. I used Zoop for a framework. The site itself is working perfect, but the .htaccess file shown here to remove the "index.php" is not doing anything. I've tried the

RewriteRule .* http://google.com/ [L,R=301]

and it redirected me, so .htaccess override is allowed on the server.

Here is what I appended to the .htaccess file already provided in the hosting dir:

RewriteEngine on

# Canonical domain name rewrite
# Modify the next two lines to redirect to a canonical domain name.
RewriteCond %{HTTP_HOST} !^www.freebasearticles\.com(.*)$ [NC]
RewriteRule ^(.*)$ http://www.freebasearticles.com/$1 [L,R=301]

# Modify the RewriteBase if you are using Zoop in a
# subdirectory and rewrite rules don't work.
RewriteBase /

# Rewrite URLs to the form 'index.php/x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

The server is Unix with Apache 2.

So, what am I not doing right?

OMT 23 Mar 2009

Hello and Welcome

First I would like to say Welcome to the Zoop community.

I accessed the home page for your site and was provided the link list below. Then I change the link to what I think you would expect if the rule was working, but I got 500 Internal error page. Can you look at the error log file for Apache around 11:12 MST on 3/23/09 and post the error? This will help to figure out what is going on.

Provided: http://www.freebasearticles.com/index.php/browse_category/1/10/advertisi...

Expected: http://www.freebasearticles.com/browse_category/1/10/advertising

Note: I always added the Rewrite Code within a directive in my Apache file. So if your files existed in /var/www I would change your .htaccess to look like the example below.

<Directory "/var/www">
<IfModule mod_rewrite.c>
  RewriteEngine on
  # Modify the RewriteBase if you are using Zoop in a
  # subdirectory and rewrite rules don't work.
  RewriteBase /
 
  # Rewrite URLs to the form 'index.php/x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
</Directory>

jmorant@cloud9l... 23 Mar 2009

Hello again

Thank you for the reply.

Tried to put the "Directory "/var/www" ... /Directory" in the .htaccess-file. After that the site became totally unreachable, with "Internal error 500" reply when attempting to load in the browser. I changed the directory from "/var/www", because it was not the one, but even with the correct one it was still having "error 500". The error log provided some information:

"/home/[user]/public_html/.htaccess: Directory not allowed here"

By the time this message showed up the "Directory "/var/www"" was changed to the one in the log.

Commenting out the "Directory..." statement got the site up and running, but still with the "index.php" in the url?

Any suggestions?

OMT 24 Mar 2009

Now Try

With the .htaccess set back the way you expect it to be please access the URL the way would if the index.php was taken out. You will get a page for a 500 Internal Error at that point please retrieve the error from you Apache log and post it here. Without the error log it is hard to say what might be going on.

jmorant@cloud9l... 26 Mar 2009

The error log

That is what the error log is saying:

[Mon Mar 30 05:22:20 2009] [alert] [client 85.130.26.17] /home/[user]/public_html/.htaccess: Directory not allowed here

The site files are in www, but there is a mirror (not made by me) in public_html.

Edit: When I removed the Directory statement from the .htaccess file, I tiped in an "index.php"-free URL, and I got redirected to the analogue URL with "index.php" in it. No error whatsoever, just a redirect to the old style of URLs

OMT 30 Mar 2009

Rule Order

When I type in http://www.freebasearticles.com/ I am getting a 302 redirect to http://www.freebasearticles.com/index.php/browse_category/1/10/advertisi.... It looks like there is a redirect rule running before the rewrite rule which might be causing all the issues. Have you setup any other rules in parent folders?

jmorant@cloud9l... 30 Mar 2009

No.

No other rules, the current .htaccess is in top folder, and no redirects. Looks like something from httpd.conf, to which I do not have access to. Other problem is that the hosting is not allowing RewriteLog, so I cannot give you more information than what I had already gave. Strange thing is, that I tried googling for rewrite rules, and everywhere there is the same rule as in the example here. And yet it is not working. Could it be hosting-related?

OMT 02 Apr 2009

Hosting Issue

This could possibly be a hosting limitation it is hard to tell since your host will not let you log more information.

One last thing to check would be if you are using any redirect rules in your PHP code since we have ruled out the Web Server. If you are using the $this->zoneRedirect(), self::zoneRedirect(), or Redirect() it may be part of the problem. Look in your initZone, initPage, and pageDefault functions in your Default Zone. If there is a reference to index.php in any of those functions remove it. If you are using zoneRedirect switch to Redirect since I had an issue with zoneRedirect inferring index.php when it did not need to.

jmorant@cloud9l... 03 Apr 2009

More info

I wrote a ticket to the hosting support, and they said that the .htaccess itself is OK, but there is an issue with the software (the PHP files). In the Default zone there is a Redirect which I put there, (not zoneRedirect), and it had "index.php" in it. I removed it and now the browser says that this redirect will never be completed. I went through the code of Zoop, and I found out that there is "app_url_rewrite" directive in config.php, which is set to "true" from the very beginning. I browsed the code in globals.php, and there also IS code (depending on the "app_url_rewrite" directive), which should rewrite the URLs (not only in matter of adding or removing "index.php"). On top of that, at the end of this file there is a comment, that says:

/******** URL Rewrite example ****************\
*
* This is an example of the mod_rewrite commands
* to put in your httpd.conf file to get rid of
* index.php in the URL line.
*
RewriteEngine on

RewriteCond %{THE_REQUEST} !^(.*)/resources(.*)$
RewriteRule ^(/.*)$ /home/dir/path/to/index.php [E=PATH_INFO:$1]

RewriteCond %{THE_REQUEST} ^(.*)/resources/(.*)$
RewriteRule ^/resources/(.*)$ /home/dir/path/to/resources/$1

RewriteLog logs/test-rewritelog
RewriteLogLevel 9
*
* Cool, eh? Change the paths apropriately.
* This assumes that all your normal files are in /resources/ somewhere, including images, css, js, etc
\******** End URL Rewrite example ************/

Should I try the directives shown here, and if yes, a little more info on what is understood here as "resources" will be appreciated.

OMT 04 Apr 2009

Made a little testing...

I played around with the code of globals.php. It seems that even as "app_url_rewrite" is set to TRUE and that is visible to the globals.php, it just makes no difference to it, and it adds "index.php" to the URL. Could this be a bug?

OMT 06 Apr 2009

What does the Redirect call look like

Can you post the code for the Redirect call? When I have the Redirect Apache rule setup and I want to perform a Redirect to a zone using PHP I Redirect to the absolute path without the Domain. Please check the example below.

Zone: test
Domain: www.test.com

So if I want to redirect to http://www.test.com/test I would do the following in the Zone code:

Redirect('/test');

jmorant@cloud9l... 06 Apr 2009

Redirect

Sure, here it is:

Redirect('http://www.freebasearticles.com/index.php/browse_category/1/10/advertising');

If it is like this:

Redirect('http://www.freebasearticles.com/browse_category/1/10/advertising');

it gives me an error page "redirect cannot be completed".

OMT 06 Apr 2009

Update

The Redirect shown in the previous post is no longer there. I replaced it with a default homepage and now it is not redirecting to the "Advertising" category.

OMT 08 Apr 2009

The Link Works For Me

I just pasted the URL below and it correctly displayed the page without redirecting to index.php. Are you still having an issue?

http://www.freebasearticles.com/browse_category/1/10/advertising

jmorant@cloud9l... 13 Apr 2009

Sort of

I made a mirror of the site on my personal Apache at home. It worked flawlessly. It appears that the issue is on only on Apache2 servers. I've been working on the .htaccess today, so this working link might be an echo of my efforts, but yet not all links work properly when I typed them like that. I need to know what may be the difference between the .htaccess syntax in Apache1.3 and 2, since under 1.3 there is no problem with that at all.

OMT 13 Apr 2009

Apache 2

I use Apache2 with the listed code without any issue. Actually I have never used Apache 1.x so I am not sure the difference lies in the Apache versions as much as with the Web Server setup by the ISP. You may have you home setup closer to the default Apache setup which allows the code to function as intended. Please let me know if you find the cause of the issue so it can be logged here for other users.

jmorant@cloud9l... 21 Apr 2009

Sure:)

Been talking to other people as well - they all think that it is a hosting-related problem (setup of the Apache). A friend of mine also looked around the code of Zoop and found nothing to be the reason of that behaviour. The moment I have a working resolution I'll post it here to be used from other people too. This issue with shared hostings could be a seroius drawback for Zoop and should be removed.

OMT 22 Apr 2009

Yes, i think yes. mee to i

Yes, i think yes. mee to i have these problems.

Maria,
-----
submit site to directory

mariasan 04 Dec 2009