SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Evangelist
    Join Date
    Feb 2005
    Posts
    530
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need advice for .htaccess rewrite for ExpressionEngine 2

    I have recently upgraded my site from EE 1 to EE 2 and it appears to have resulted in some of my .htacess rewrites to change the URL structure no longer working.

    My original setup was this:

    Code:
    RewriteRule ^/?((403|404|About|Chat|Contact|Copyright|Search)(/.*)?)$ /Westeros/$1 [L]
    RewriteRule ^/?((ASoIaF|Digest|Images|Login|Store|Updates|Westeros|member)(/.*)?)$ /index.php/$1 [L]
    I've also tried this:

    Code:
    RewriteRule ^/?((403|404|About|Chat|Contact|Copyright|Search)(/.*)?)$ /index.php/Westeros/$1 [L]
    RewriteRule ^/?((ASoIaF|Digest|Images|Login|Store|Updates|member)(/.*)?)$ /index.php/$1 [L]
    There's a couple of different things going on and some work and some don't, in both of these scenarios.

    1) http://www.westeros.org/Updates/ works fine. Updates is a template group.
    2) http://www.westeros.org/Search/ does not work. Search is a template within the Westeros template group. It does work to access it as http://www.westeros.org/index.php/Westeros/Search/.
    3) http://www.westeros.org/About/ does not work. About is a Page with its URI set to /Westeros/About/. It does work to access it as http://www.westeros.org/index.php/Westeros/About/.

    I imagine there's been some internal changes in URL handling between EE 1 and EE 2, but I can't quite grasp how it could stop these rewrites from happening. Isn't a rewrite the first thing that gets done, so shouldn't EE be seeing the rewritten URLs and nothing else?

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,170
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    I just use this for EE and it works a treat:

    Code:
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*) index.php/$1 [L]

  3. #3
    SitePoint Evangelist
    Join Date
    Feb 2005
    Posts
    530
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for responding. However, I need more than just the standard index.php rewrite since I sometimes need to remove a template group as well or part of a Page URI. The rewrites that need just index.php removed are working for me.

  4. #4
    SitePoint Evangelist
    Join Date
    Feb 2005
    Posts
    530
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Someone pointed me to a blog post from Pixel & Tonic (http://pixelandtonic.com/blog/making-pt-structure) which included a rewrite example:

    Code:
    RewriteRule ^index.php/(playa|wygwam|fieldframe|ffmatrix)(/[^\/]+)?(/.+)?$ /index.php/ee$2/$1/$3 [NC,L]
    
    This little redirect (coupled with a standard index.php redirect) will take an incoming URI like /playa, and turn it into /index.php/ee/playa behind the scenes.
    I just can't figure out if that can apply to my situation, in part because I don't quite see why he's starting the rule with index.php when he says the incoming URI will be /playa. I also don't see why its /ee$2/ and not just /ee/. But from the description it is doing what I need, allowing for a template group to be removed. It seems like that would also work for part of a Page URI, unless something internally prevents that.

  5. #5
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,650
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Linda,

    PHP includes (templates) are not performed via your .htaccess file so Ralph's response looks to be the best option.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  6. #6
    SitePoint Evangelist
    Join Date
    Feb 2005
    Posts
    530
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am afraid I don't follow that at all. I am not trying to do any php includes. When I mentioned templates and template groups it was in reference to how ExpressionEngine structures its content, in case someone here was familiar with it.

    Ralph's method won't work, unfortunately, because I need more than just the index.php removed from the URLs. What I had worked fine for EE 1 but broke after I upgraded to EE 2. I am trying to track down why, since I don't know enough myself about either .htaccess or EE.

  7. #7
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,170
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    Could you say a bit more about why you need certain template groups removed? If you just use the code I gave, you'd be able to access year search page at

    http://www.westeros.org/Westeros/search

    which is normally how it should be presented with EE. If you are wanting to remove the /Westeros/ from that, it would be better to put the search page in its own /search template group. That would save you a lot of problems.

    Is that basically the sort of thing you are trying to do, or is it more complex than that?

  8. #8
    SitePoint Evangelist
    Join Date
    Feb 2005
    Posts
    530
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I need to also remove /Westeros/ from that. If it was just Search, I could have created its own template group, but I have a number of templates that need to display right after the domain and adding a template group for each just didn't seem ideal. So, on EE 1 I set them all up in the Westeros template group and used .htaccess to remove the group and it worked just fine. But, that's no longer the case now that I have upgraded to EE 2.

    The other issue is with pages, where I also added in a site-identifier as part of the URI (I run multiple sites off one EE install, and since two pages cannot have the same URI, I needed to separate them out) and used .htaccess to remove that part. That, too, worked in EE 1 but breaks in EE 2.

    In part, I am just trying to figure out why it breaks now and if there's any work-around that allows me to keep my current URLs, since anything else would mean a lot of restructuring of the site. I am told by others that the example I posted before dklynn's post should work, and as far as I can tell, it also removes the template group, so that would suggest this is still doable in EE 2.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •