1

I'd like to take any URL where segment_1 == "supernav" and remove that segment. So this:

http://alpha.ced.berkeley.edu/supernav/gallery/

Would become this:

http://alpha.ced.berkeley.edu/gallery/

How can I do this?

  • 1
    Are you trying to simply hide the segment from your template, or redirect users from one URL to another? – Adrian Macneil Dec 16 '12 at 0:37
4

I'd create a template group called supernav, and put this in its index template:

{redirect="{segment_2}/{segment_3}"}

(If there's no 3rd segment present, EE will ignore it.)

| improve this answer | |
  • Tricky part is I'm using Structure, so templates are quite used the same way... – Brandon Durham Dec 17 '12 at 15:48
1

If you're not actually talking about doing a redirect (it's not quite clear from your question for me) then you may want to consider using Freebie for this:

http://devot-ee.com/add-ons/freebie

In the freebie extension settings you can set supernav to be ignored so, any time you hit http://alpha.ced.berkeley.edu/gallery/ you are really hitting http://alpha.ced.berkeley.edu/supernav/gallery/

And of course you would make sure in your hrefs that you removed supernav/.

| improve this answer | |
  • I've tried Freebie and I can never seem to get it to work correctly. Not sure why. – Brandon Durham Dec 17 '12 at 15:44
1

Here are a couple mod_rewrite options to try in your .htaccess file to remove the "supernav" segment of your URL:

RewriteEngine On
RewriteBase /
RewriteRule ^supernav/gallery/$ /gallery [L]

or

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ supernav/$1 [L]

Worth taking a look at...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.