Jump to content

How to customize urls?


nghi
 Share

Recommended Posts

How would I go about customizing urls? I'm trying remove the portal parent from my url

E.G

/portal/catering/decorator

/portal/catering

/portal/restaurants/north

/portal/restaurants/south

to

/catering/decorator

/catering

/restaurants/north

/restaurants/south

5xxWvAT.png

Link to comment
Share on other sites

I have a category page call portal and I have child pages within that category.

I would like to be able to access my child pages

like this

http://mywebsite.com/catering

instead of this

http://mywebsite.com/portal/catering

but still keep my child pages within the portal category.

You can also add this to your .htaccess file.

RewriteEngine On
RewriteBase   /
RewriteRule ^portal/(.*)$ $1 [R,NC,NS,L]

Basically it's just removing portal

/portal/anything/anything

to 

/anything/anything

e.g.

/portal/catering/decorator -> /catering/decorator 

/portal/weddings/rentals -> /weddings/rentals

Link to comment
Share on other sites

I think this is not a good solution, ...

   Basically it's just removing portal

/portal/anything/anything

to 

/anything/anything

e.g.

/portal/catering/decorator -> /catering/decorator 

/portal/weddings/rentals -> /weddings/rentals

... because what's about if someone has a page tree like this:

/portal/

/something1/

/something2/

/something3/

Than he turns on your rewriting and after that, the authors someday create pages under /portal/ like this:

/portal/anything1/

/portal/anything2/

/portal/something1/

???

Link to comment
Share on other sites

That's a good point. You'd have to account for that in your programming or tell the user to rename the page if that happens. Larger organizations sometimes use content guidelines to prevent these types of problems. I think if your pushing out that much content, enough that there's a risk of this problem happening frequently, I'm not sure I'd use mod rewrite. It may be slower than PW url segments. I'd test, but I'd expect PW to use less resources and be faster. On the other hand, making the redirect prior to loading PW, may have the advantage.

Does PW require a unique page name? If so this would not be an issue, because portal would be the page parent and anything1 would be the page name. If anything1 already exists PW would not allow you to save a new page with the same name.

PW may only require unique urls at each level in the tree. For example you can have a page named contact under the site root and a different page named contact under the about page. PW may see those as unique which would create the issue you mentioned. 

/index/contact

/index/about/contact

There may be other arguments against using mod-rewrite, but it's by far the simplest and quickest approach that less experienced coders can use. I'm glad you pointed out that issue, it hadn't crossed my mind and it's important to consider if you are going to use mod-rewrite. Thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...