Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove index from subpage path with mod_rewrite?
#1
I'm looking for help with mod_rewrite: I'd like to remove /index/ from subpage paths beneath the start page in GS.

http://www.get-simple.de/index/was-ist-getsimple/ should generally become http://www.get-simple.de/was-ist-getsimple/.

I clicked on the second example above, just out of curiosity if it would work, and it does! No 404, so it should be possible to remove the /index/ altogether?
Reply
#2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index/$1 [L]

?
Addons: blue business theme, Online Visitors, Notepad
Reply
#3
yojoe Wrote:RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index/$1 [L]

I tested that in the .htaccess but the links to subpages in the submenu were not modified, so calling these subpages the URLs still contained /index/ and by that I ran into an error
|--

Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forums/forumdisplay.php?fid=18
Reply
#4
polyfragmented Wrote:I'm looking for help with mod_rewrite: I'd like to remove /index/ from subpage paths beneath the start page in GS.

http://www.get-simple.de/index/was-ist-getsimple/ should generally become http://www.get-simple.de/was-ist-getsimple/.

I clicked on the second example above, just out of curiosity if it would work, and it does! No 404, so it should be possible to remove the /index/ altogether?

The plugin you use to generate the breadcrumbs should not include "index" in the link... Edit: No, sorry.. I presume it's just that was-ist-getsimple has index as parent. Why not make it a top level page instead?

GetSimple's default rewriterule allows anything between the base url and the slug. Other links that work are:

http://www.get-simple.de/loremipsum/was-ist-getsimple/
http://www.get-simple.de/lorem/ipsum/foo...getsimple/
....

This 'feature' is not a problem for search engines, the correct canonical url (defined by your custom/fancy permalink settings) is in the header:
Code:
<link rel="canonical" href=...

If you want to enforce the url structure (fancy or custom) you have defined in your GS settings, you can edit gsconfig.php and enable canonical redirection:
Code:
# Enable Canonical Redirects?
define('GSCANONICAL', 1);

However this does not work properly with pages that use url parameters (news managers, galleries, etc.).

It would be nice a plugin that does this, but letting you exclude certain slugs (like SimpleCache does, as it is exactly the same 'problem').
Reply
#5
Connie Wrote:I tested that in the .htaccess but the links to subpages in the submenu were not modified, so calling these subpages the URLs still contained /index/ and by that I ran into an error

Rewrite works as supposed, and redirects user where he should be redirected.
Rewrite doesn't interfere into script's code. It may work along with it (passing some variables), but it does not override script's output text. You have to change it manually according to what you want to achieve.
But then rewrite rules wouldn't be needed.
Addons: blue business theme, Online Visitors, Notepad
Reply
#6
Carlos Wrote:I presume it's just that was-ist-getsimple has index as parent. Why not make it a top level page instead?

Carlos, because the space for toplevel-pages is limited and we want to keep that as sub-page of the homepage

I think there is no real solution as the rewrite-rules plus the plugin-outputs must fit together ;=(
|--

Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forums/forumdisplay.php?fid=18
Reply
#7
Connie Wrote:because the space for toplevel-pages is limited and we want to keep that as sub-page of the homepage

Why not use a top level generic page like 'site', 'web',... as parent of those main pages?

PS I don't understand what limitation there is... You can have top level pages that are not shown in the navigation menu, don't you?
Reply
#8
Anyway here's a patch: edit /admin/inc/basic.php, at the beginning of function find_url(), line 349, insert:
Code:
if ($parent=='index') $parent='';
Reply
#9
Carlos,

I know that. But we wanted to have these pages under the HOME, shown in the right sidebar
so placing them under another, even not menu-visible page, is not our idea

and we were pondering why there must be this "index" and how to rename it if it is necessary ;=)

Cheers, Connie
|--

Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forums/forumdisplay.php?fid=18
Reply
#10
Carlos Wrote:if ($parent=='index') $parent='';
Thanks, that seems to work.

As far as "what-is-getsimple" goes, it was merely an example of what I wanted to get rid off. It's no matter of SEO or page placement either, I just don't see the need for /index/child-page/ as opposed to /some-top-level-navi/child-page/. While the system basically works that way, it looks broken to me, hence my request.

I appreciate your invested time and the working patch you delivered. Again, thanks. +1
Reply
#11
This is inline with how file based websites work
index is sibling of all other pages

There is no such thing as
index/pages

Not sure why you would want to do this.
Index is an index not a parent

as such index/index makes no sense

I would even go so far to say, we should not let index even be a parent option.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#12
Hi mates,
I got the same problem but at the moment I resolved in this way without modyfing GS
(this solution is good for a site with News Manager & I18N plugins)

PHP Code:
<div id="breadcrumbs">
You are here <?php if ($parent!='index') { 
?> » <a href="<?php echo find_url('index',null); ?>">Home</a><? } 
get_i18n_breadcrumbs(return_page_slug()); if (nm_is_single()) { 
?> » <a href="<?php nm_post_url(); ?>"><?php nm_post_title(); ?></a><?php 
?></div> 

This about the "breacrumbs" but the problem continues with the url structure
example:
http://sitename.com/index/page/subpage

P.S.
Thanks to Carlos for showing me this post.
My website made with GetSimple CMS is

Arte & Società
www.artesocieta.eu

An indipendent website about Italian Contemporary Visual Arts
Reply




Users browsing this thread: 1 Guest(s)