Local development environment in Leopard with url rewriting (re index.php)
Posted: 01 December 2008 08:21 PM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  52
Joined  05-15-2007

Hi

I want to develop and test ways of getting rid of index.php from the url in my localhost enviroment on Leopard. I need help with setting this up in localhost.

I’ve tried downloading the free version of MAMP. I’ve already got PHP, Apache and MySQL working in Leopard without MAMP but I thought MAMP would be good for testing url rewriting.

I want to use localhost on Leopard to test ways of getting rid of index.php from the url (as well as general url rewriting). Is there an easy step by step tutorial anywhere on the web on how to do this? I don’t mind not using MAMP, just whichever is the easiest way to set it up will do.

This index.php in the url has been a major stumbling block to my using ExpressionEngine. I know not all web hosts support methods of getting rid of it but I really want to remove it from the url. I’ll look for specific web hosts that support the method(s). I just need help with setting up my developing and testing environment in Leopard so I can do the url rewriting.

I’ve looked at open source cms software but the professionalism (or commitment) just doesn’t seem to be there in their forums. From what I’ve seen in the ExpressionEngine Forums I have faith someone here can point me to the right answer.

Thanks

 Signature 

Web Development at http://www.petermount.com

Profile
 
 
Posted: 02 December 2008 04:49 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  171
Joined  11-22-2006

Install MAMP.
Go to MAMP - Preferences - Apache and point the document root to your Sites folder or where you want to store your files.

Create a folder (test) in my Sites folder and copy all the EE files into it.

Open the MAMP start page in your browser.

Select phpMySQL and create a new database called test.

Open the install.php in your browser, http://localhost:8888/test/install.php

Then do a normal install of EE as if it was on a remote server.
The default username and password for the database is root

When it is all up and running create an .htaccess file in the test folder and past in the following:

RewriteEngine on
RewriteCond
$1 ^(weblog|member|search|Forum_Name|TemplateGroup_4_Name|P[0-9]{2,8}) [NC]
RewriteRule
^(.*)$ index.php/$1 [L]

This is detailed in the “Include” method of the wiki entry for removing index.php

The key difference to the wiki code is the last line that has the leading / before index.php removed (original below).

RewriteRule ^(.*)$ /index.php/$1 [L]

 Signature 

pfweb.co.uk

Profile
 
 
Posted: 02 December 2008 12:14 PM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  52
Joined  05-15-2007

Thanks Paul

That helped with the url (it now shows at http://localhost:8888/) but now the css isn’t working. Will I need to change the link to the css in the template?

The links to the css on the home page index template is currently:

<link rel='stylesheet' type='text/css' media='all' href='{stylesheet={my_template_group}/site_css}' />
<
style type='text/css' media='screen'>@import "{stylesheet={my_template_group}/site_css}";</style>

Also, the other pages don’t work. Before the .htaccess file the second page could be found at:

http://localhost:8888/EE/index.php/site/about/

Now I just get a “page not found” error even when I try to take index.php or “EE/index.php/site” out of the url.

Thanks

 Signature 

Web Development at http://www.petermount.com

Profile
 
 
Posted: 02 December 2008 01:37 PM   [ Ignore ]   [ # 3 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  171
Joined  11-22-2006

I prefer to keep my CSS as an external file so I use either:

<link rel=‘stylesheet’ type=‘text/css’ media=‘all’ href=/EE/css/xyz.css’ />

or

<link rel=‘stylesheet’ type=‘text/css’ media=‘all’ http://localhost:8888/EE/css/xyz.css’ />

I have several folders in my sites folder (which is my Apache document root folder), so my url would be

http://localhost:8888/EE/

which would automatically display the site/index.php template by default.
Then for a deeper link:

http://localhost:8888/EE/site/about/

 Signature 

pfweb.co.uk

Profile
 
 
Posted: 03 December 2008 04:08 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  8
Joined  11-12-2008

I’ve been trying all evening to get this to work - I’ve set up a totally vanilla MAMP, and I’m using the base htdocs folder for EE, nothing else in it (so index.php is at htdocs/index.php)

I can’t get any of the methods described in the Wiki to work.  Either I get no effect at all - which happens with the include method - or things go haywire, for example I can’t access the CP, which happens with the exclude method.

mod_rewrite is enabled in Apache, and the httpd error isn’t telling me anything interesting…

I guess I’ll give up for now and go and catch some sleep.

Profile
 
 
Posted: 04 December 2008 02:09 PM   [ Ignore ]   [ # 5 ]  
Grad Student
Avatar
Rank
Total Posts:  52
Joined  05-15-2007

I made an external css file and it works with the home page. But now I’m having trouble with the menu, even when I click on the menu item for the home page. I just get a page not found error.

How should I change the menu items to reflect the right urls? I remember there is some page in the control panel for the url structure, should I change the settings in that as well?

How would this affect pagination links?

I also need to put the menu in a include file. I’ll have to figure out how to do that in EE.

Thanks

 Signature 

Web Development at http://www.petermount.com

Profile
 
 
Posted: 04 December 2008 03:35 PM   [ Ignore ]   [ # 6 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  171
Joined  11-22-2006

The url’s can be set in so many ways it depends on how you have them set up.

CP Home › Admin › Weblog Administration › Weblog Management › Weblog preferneces ›  Path settings.

What code are you using in the template to generate url’s?

Read the User Guide, it’s all there.
Embed templates in templates.
url paths

There are so many ways to do things it’s hard to track down what you are doing wrong.

 Signature 

pfweb.co.uk

Profile
 
 
Posted: 05 December 2008 04:03 AM   [ Ignore ]   [ # 7 ]  
Grad Student
Avatar
Rank
Total Posts:  52
Joined  05-15-2007

Hi Paul

The code in the template to generate the urls from the menu is:

<ul id="navbar">
  <
li id="home"><a href="{homepage}" title="Home">Home</a></li>
  <
li id="about"><a href="{path={my_template_group}/about}" title="About">About</a></li>
  <
li id="archives"><a href="{path={my_template_group}/archives}" title="Archives">Archives</a></li>
  <
li id="contact">{encode="{webmaster_email}" title="Contact"}</li>
</
ul>

I’ll have a look at the other stuff you mentioned

Thanks

 Signature 

Web Development at http://www.petermount.com

Profile
 
 
Posted: 05 December 2008 04:11 AM   [ Ignore ]   [ # 8 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  171
Joined  11-22-2006

Do you have

{assign_variable:my_template_group="xyz"}


at the top of each template to define the variable {my_template_group}?

 Signature 

pfweb.co.uk

Profile
 
 
Posted: 05 December 2008 07:21 PM   [ Ignore ]   [ # 9 ]  
Grad Student
Avatar
Rank
Total Posts:  52
Joined  05-15-2007

Hi

The first two lines are:

{assign_variable:my_weblog="default_site"}
{assign_variable
:my_template_group="site"}

Thanks

 Signature 

Web Development at http://www.petermount.com

Profile
 
 
Posted: 06 December 2008 04:09 AM   [ Ignore ]   [ # 10 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  171
Joined  11-22-2006

Does your .htacces file contain the template name you are using (site in the example below)

RewriteCond $1 ^(site|member|search|P[0-9]{2,8}) [NC]


If that doesn’t solve it I am at a loss to suggest anything else, and without having access to your computer I’m not sure how I can help further.

 Signature 

pfweb.co.uk

Profile
 
 
Posted: 06 December 2008 04:53 AM   [ Ignore ]   [ # 11 ]  
Grad Student
Avatar
Rank
Total Posts:  52
Joined  05-15-2007
Paul Frost (orienteer) - 06 December 2008 04:09 AM

Does your .htacces file contain the template name you are using (site in the example below)

RewriteCond $1 ^(site|member|search|P[0-9]{2,8}) [NC]


If that doesn’t solve it I am at a loss to suggest anything else, and without having access to your computer I’m not sure how I can help further.

Paul, with your help it now works on localhost.

.htaccess currently reads:

#for EE
RewriteEngine on
#RewriteCond $1 ^(weblog|member|search|Forum_Name|TemplateGroup_4_Name|P[0-9]{2,8}) [NC]
RewriteCond $1 ^(site|about|archives|P[0-9]{2,8}) [NC]
RewriteRule
^(.*)$ index.php/$1 [L]

The menu in each template currently reads:

<!--
<
ul id="navbar">
  <
li id="home"><a href="{homepage}" title="Home">Home</a></li>
  <
li id="about"><a href="{path={my_template_group}/about}" title="About">About</a></li>
  <
li id="archives"><a href="{path={my_template_group}/archives}" title="Archives">Archives</a></li>
  <
li id="contact">{encode="{webmaster_email}" title="Contact"}</li>
</
ul>
-->
<
ul id="navbar">
  <
li id="home"><a href="/" title="Home">Home</a></li>
  <
li id="about"><a href="/about/" title="About">About</a></li>
  <
li id="archives"><a href="/archives/" title="Archives">Archives</a></li>
  <
li id="contact">{encode="{webmaster_email}" title="Contact"}</li>
</
ul>

The commented out bit was the original code for the nav code.

I’ve currently got it working without include files for the menu etc but I feel I’ve turned a corner.

Thank you Paul for your help. Do have a good day.

 Signature 

Web Development at http://www.petermount.com

Profile
 
 
Posted: 06 December 2008 05:27 AM   [ Ignore ]   [ # 12 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  171
Joined  11-22-2006

Glad you got it sorted, I have pulled out my hair enough with these sort of issues to know how it feels.

 Signature 

pfweb.co.uk

Profile
 
 
   
 
 
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 1149, on July 16, 2007 09:33 AM
Total Registered Members: 66389 Total Logged-in Users: 48
Total Topics: 84714 Total Anonymous Users: 18
Total Replies: 454689 Total Guests: 188
Total Posts: 539403    
Members ( View Memberlist )