1 of 3
1
{auto_path} problem once index.php removed?
Posted: 12 January 2005 09:03 AM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  112
Joined  06-13-2003

I have successfully implemented the whole rewrite engine thing in an htaccess file in order to remove “index.php” from the URLs. Seems to work like a charm but I can’t figure out one thing:

(Note: in my setup, “index.php” is actually “main”)

The one place the “index.php” STILL shows up in a URL is when I use {auto_path} to paginate archives.

This is the URL generated to go to the second page of archives:

http://www.mysite.com/meetings/archive/main/P32/

So, not only is index.php (main) showing up but it’s in a funky position in the URL.

The only other place I can recall using the {auto_path} varable is in the search results template and I checked that…the URLs generated by it are perfect.

The whole site is functioning correctly except for this one thing so it would seem to me that for once, I didn’t screw this up. Or did I? In any case, any idea how to correct this?

Profile
 
 
Posted: 12 January 2005 11:02 AM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9853
Joined  06-19-2002

How exactly are you using it in your EE code?

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 12 January 2005 11:13 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
RankRank
Total Posts:  112
Joined  06-13-2003

Hi Chris. Thanks for your help (again!). grin

For the {auto_path} variable in my archive template, this is what I have within the {exp:weblog:entries} tag:

{paginate}
{if previous_page}
<a href=”{auto_path}”>Previous Page</a> 
{/if}
{if next_page}
<a href=”{auto_path}”>Next Page</a>
{/if}
{/paginate}

For the htaccess file:

DirectoryIndex main index index.php index.shtml index.html index.htm
<Files main>
ForceType application/x-httpd-php
</Files>

RewriteEngine on
RewriteCond $1 !^content.*
RewriteCond $1 !^images.*
RewriteCond $1 !^main.*
RewriteRule ^(.*) main/$1 [NC,L]

Profile
 
 
Posted: 12 January 2005 11:45 AM   [ Ignore ]   [ # 3 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9853
Joined  06-19-2002

Look under Admin > General Configuration and make sure you have the “Name of your site’s index page” setting blank.

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 12 January 2005 11:57 AM   [ Ignore ]   [ # 4 ]  
Lab Assistant
RankRank
Total Posts:  112
Joined  06-13-2003

Yup. It’s blank. And all weblogs’ path settings under weblog management have the “index.php” segment removed from them. That’s why it’s so weird…I mean, everything else works fine.

Profile
 
 
Posted: 12 January 2005 02:09 PM   [ Ignore ]   [ # 5 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7516
Joined  08-05-2002

I am doing similar rewriting in my .htaccess file, and I cannot duplicate this problem on my own site.  However, while digging through the code, I found this bit in the mod.weblog.php file around line 1625:

if ( ! eregi(”.php$”, SELF) AND ! ereg(SELF, $this->basepath))
{
    $this->basepath .= SELF.’/’;
}

SELF is a constant that is equal the the name of the main index page (‘main’ in your case), so I wonder if this is causing the addition.  Could you remove it from your mod.weblog.php file and see if it helps?

 Signature 


♖  ♘  ♗  ♔  ♕  ♗  ♘  ♖
♙  ♙  ♙  ♙  ♙  ♙  ♙  ♙
☐  ☐  ☐  ☐  ☐  ☐  ☐  ☐
☐  ☐  ☐  ☐  ☐  ☐  ☐  ☐
☐  ☐  ☐  ☐  ☐  ☐  ☐  ☐
☐  ☐  ☐  ☐  ☐  ☐  ☐  ☐
♟  ♟  ♟  ♟  ♟  ♟  ♟  ♟
♜  ♞  ♝  ♚  ♛  ♝  ♞  ♜

Profile
 
 
Posted: 12 January 2005 03:34 PM   [ Ignore ]   [ # 6 ]  
Lab Assistant
RankRank
Total Posts:  112
Joined  06-13-2003

I commented out those lines and…it worked. Thanks for your help with this. grin

Which, of course, leads me to my next question:

Why does it work? How come the problem happens to me and not to you? What effect will removing that snippet have on other functions since it’s in the code for a reason?

Or am I jumping the gun and need to take a deep, deep breath…and this was just a test to let you know the effect of removing that code? Gosh, I’d hate to now be resigned to a lifetime of needing to remember to edit mod.weblog.php every time there is an update.

Profile
 
 
Posted: 12 January 2005 07:46 PM   [ Ignore ]   [ # 7 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7516
Joined  08-05-2002

Well, the logic above is meant to make sure if you are at the URL:  http://www.yoursite.com/, then the ‘index.php’ is added before the adding of the template group, template, and pagination segments.  Ex:  http://www.yoursite.com/index.php/P20/

The problem occurs because your index.php had its name changed to drop the .php AND because .htaccess has allowed the dropping of index.php (‘main’ now) from the URL, thus EE thinks you are at the main page of your site and adds the ‘main’ to the end of the URL before adding the pagination segment. 

Just wondering, why did you change the name of your index.php file if you were just going to drop it anyway?

 Signature 


♖  ♘  ♗  ♔  ♕  ♗  ♘  ♖
♙  ♙  ♙  ♙  ♙  ♙  ♙  ♙
☐  ☐  ☐  ☐  ☐  ☐  ☐  ☐
☐  ☐  ☐  ☐  ☐  ☐  ☐  ☐
☐  ☐  ☐  ☐  ☐  ☐  ☐  ☐
☐  ☐  ☐  ☐  ☐  ☐  ☐  ☐
♟  ♟  ♟  ♟  ♟  ♟  ♟  ♟
♜  ♞  ♝  ♚  ♛  ♝  ♞  ♜

Profile
 
 
Posted: 12 January 2005 08:13 PM   [ Ignore ]   [ # 8 ]  
Lab Assistant
RankRank
Total Posts:  112
Joined  06-13-2003

Gosh, now that you ask, it does seem pretty stupid, doesn’t it?

I changed the name of index.php because I didn’t have any intention of dropping it entirely…and this was mainly because I didn’t understand the steps for doing the rewrite stuff. Guess I got adventurous. No, actually, having that extra segment in there was really bugging me. And my client wasn’t real happy with it either.

So, given your last question to me, it sounds like if I revert back to index.php, everything will be fine and dandy…?

Uh…are the steps for reverting back to index.php obvious or will I risk another meltdown in the process?

Profile
 
 
Posted: 12 January 2005 10:13 PM   [ Ignore ]   [ # 9 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7516
Joined  08-05-2002

Silly, at the very least.

I believe reverting back should fix it, yes.  Rick and I never expected someone to change the name of the index.php *and* make it disappear, so hence why the slight problem here.

I think you can just change the file ‘main’ back to index.php and then update the last line of your htaccess file to this:  RewriteRule ^(.*) index.php/$1 [NC,L]

 Signature 


♖  ♘  ♗  ♔  ♕  ♗  ♘  ♖
♙  ♙  ♙  ♙  ♙  ♙  ♙  ♙
☐  ☐  ☐  ☐  ☐  ☐  ☐  ☐
☐  ☐  ☐  ☐  ☐  ☐  ☐  ☐
☐  ☐  ☐  ☐  ☐  ☐  ☐  ☐
☐  ☐  ☐  ☐  ☐  ☐  ☐  ☐
♟  ♟  ♟  ♟  ♟  ♟  ♟  ♟
♜  ♞  ♝  ♚  ♛  ♝  ♞  ♜

Profile
 
 
Posted: 13 January 2005 04:59 AM   [ Ignore ]   [ # 10 ]  
Lab Assistant
RankRank
Total Posts:  112
Joined  06-13-2003

It worked! It worked! Whew!! Thanks so much! One last quickie which I think is obvious but just want to make sure:

I can completely dump this part of the htaccess file, right?

DirectoryIndex main index index.php index.shtml index.html index.htm

<Files main>
ForceType application/x-httpd-php
</Files>

Profile
 
 
Posted: 13 January 2005 08:30 AM   [ Ignore ]   [ # 11 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7516
Joined  08-05-2002

I would still keep the DirectoryIndex part, just remove the ‘main index’ part of it.

 Signature 


♖  ♘  ♗  ♔  ♕  ♗  ♘  ♖
♙  ♙  ♙  ♙  ♙  ♙  ♙  ♙
☐  ☐  ☐  ☐  ☐  ☐  ☐  ☐
☐  ☐  ☐  ☐  ☐  ☐  ☐  ☐
☐  ☐  ☐  ☐  ☐  ☐  ☐  ☐
☐  ☐  ☐  ☐  ☐  ☐  ☐  ☐
♟  ♟  ♟  ♟  ♟  ♟  ♟  ♟
♜  ♞  ♝  ♚  ♛  ♝  ♞  ♜

Profile
 
 
Posted: 28 January 2005 02:21 AM   [ Ignore ]   [ # 12 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  432
Joined  10-18-2004

I actually had the same problem: index.php mysteriously appeared in the {auto_path} variable.

My .htaccess file looks something like this:

RewriteEngine On
RewriteCond $1 !^(cms|css|pdf|images|index\.php).*
RewriteRule ^(.*) index.php/$1 [NC,L]

Am I right in concluding that the only way to solve this problem is to comment out the $this->basepath .= SELF.’/’; line in mod.weblog.php? Like Pavia, I’d rather not edit the file every time there is an update…

 Signature 

Low: the Pro Network member who brought you Low Variables, Low NoSpam, Low Seg2Cat and many more...

Profile
 
 
Posted: 28 January 2005 07:40 AM   [ Ignore ]   [ # 13 ]  
Lab Assistant
RankRank
Total Posts:  112
Joined  06-13-2003

Lodewijk, even though Paul’s workaround—removing some code from mod.weblog.php—worked, the ultimate solution for me was to go back to using “index.php”. Go through this thread again—you’ll see that I had changed it to “main” in order to rid myself of the .php extension. Apparently, that was sort of dumb.

But from what you say, your index.php file is actually called index.php so, um…hmmm…I guess I have no wisdom to impart to you. Sorry. grin

Profile
 
 
Posted: 28 January 2005 08:02 AM   [ Ignore ]   [ # 14 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  432
Joined  10-18-2004

> But from what you say, your index.php file is actually called index.php

I did change it to something else before, but changed it back to index.php the moment I learned how the whole thing can be removed from the URI using the correct statements in the .htaccess file.

Nevertheless, after changing the filename back to index.php, the problem remained. Removing the line from mod.weblog.php solved the problem. Kinda. smile

But If you say all was well with you, I’ll just have another crack at it and triple-check my code. wink

 Signature 

Low: the Pro Network member who brought you Low Variables, Low NoSpam, Low Seg2Cat and many more...

Profile
 
 
Posted: 28 January 2005 08:50 AM   [ Ignore ]   [ # 15 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  432
Joined  10-18-2004

Okay, now I’m postitive that it’s not me! I reproduced the same problem with a clean installation, EE 1.2.1 build 20050115. I tried different .htaccess rules and syntaxes, but the problem persists (up to a point I nearly threw my brand new monitor out of the window, 8 stories up). The only way to solve it is to comment out this in mod.weblog.php:

if ( ! ereg(SELF, $this->basepath))
{
  $this
->basepath .= SELF.'/';
}

...or do I need to quadruple-check my code?

 Signature 

Low: the Pro Network member who brought you Low Variables, Low NoSpam, Low Seg2Cat and many more...

Profile
 
 
Posted: 28 January 2005 09:27 AM   [ Ignore ]   [ # 16 ]  
Lab Assistant
RankRank
Total Posts:  112
Joined  06-13-2003

OH NO!!! Ever since the upgrade to Build 20050123, it’s back! It finally dawned on me to take a look. :-(((

And I’m only 4 stories up!

Er, now what…?

Profile
 
 
Posted: 31 January 2005 01:32 AM   [ Ignore ]   [ # 17 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  432
Joined  10-18-2004

*looks around for pmachine staff*

Paul? Chris? Rick? Anyone?!?

 Signature 

Low: the Pro Network member who brought you Low Variables, Low NoSpam, Low Seg2Cat and many more...

Profile
 
 
Posted: 31 January 2005 01:56 AM   [ Ignore ]   [ # 18 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9853
Joined  06-19-2002

As far as I know, this should be included with the next bug fix release, whenever that is put out.  I don’t know what changes Paul had made to the file.

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
   
1 of 3
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1743, on December 02, 2009 03:47 PM
Total Registered Members: 120562 Total Logged-in Users: 60
Total Topics: 126608 Total Anonymous Users: 32
Total Replies: 665584 Total Guests: 352
Total Posts: 792192    
Members ( View Memberlist )