Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
After following the blog tutorial on the site, I now have a very functional blog which is amazing. I also use pretty urls to make everything more SEOable. The problem is, the URL does not follow the links correctly.

meaning:

when you click on the link to the blog list (soundblog.php) you get
Code: Select all
mywebsite.com/soundblog/


and all the blog posts are displayed. however, when you click on a post the url changes to

Code: Select all
mywebsite.com/blog/folder/name-of-post.html 


I want the url to read
Code: Select all
mywebsite.com/soundblog/folder/name-of-post.html 
because thats the logical progression. is this possible?

here is my mod rewrite

Code: Select all
Options +FollowSymlinks -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On

#If your website is installed in a subfolder, change the line below to reflect the path to the subfolder.
#e.g. for http://www.example.com/subdomain1/subdomain2/ make it RewriteBase /subdomain1/subdomain2
RewriteBase /

#If you wish to use a custom 404 page, place a file named 404.php in your website's root and uncomment the line below.
#If your website is installed in a subfolder, change the line below to reflect the path to the subfolder.
#e.g. for http://www.example.com/subdomain1/subdomain2/ make it ErrorDocument 404 /subdomain1/subdomain2/404.php
#ErrorDocument 404 /404.php

#If your site begins with 'www', uncomment the following two lines
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


#DO NOT EDIT BELOW THIS

RewriteRule ^index.php$ "" [R=301,L,QSA]

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule . - [L]

#soundblog.php
RewriteRule ^soundblog$ "$0/" [R=301,L,QSA]
RewriteRule ^soundblog/$ soundblog.php [L,QSA]
RewriteRule ^soundblog/.*?([^\.\/]*)\.html$ soundblog.php?pname=$1 [L,QSA]
RewriteRule ^soundblog/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ soundblog.php?d=$1$2$3 [L,QSA]
RewriteRule ^soundblog/[^\.]*?([^/\.]*)/$ soundblog.php?fname=$1 [L,QSA]
RewriteRule ^soundblog/[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]

#contact.php
RewriteRule ^contact$ "$0/" [R=301,L,QSA]
RewriteRule ^contact/$ contact.php [L,QSA]
RewriteRule ^contact/.*?([^\.\/]*)\.html$ contact.php?pname=$1 [L,QSA]
RewriteRule ^contact/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ contact.php?d=$1$2$3 [L,QSA]
RewriteRule ^contact/[^\.]*?([^/\.]*)/$ contact.php?fname=$1 [L,QSA]
RewriteRule ^contact/[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]

#blog.php
RewriteRule ^blog$ "$0/" [R=301,L,QSA]
RewriteRule ^blog/$ blog.php [L,QSA]
RewriteRule ^blog/.*?([^\.\/]*)\.html$ blog.php?pname=$1 [L,QSA]
RewriteRule ^blog/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ blog.php?d=$1$2$3 [L,QSA]
RewriteRule ^blog/[^\.]*?([^/\.]*)/$ blog.php?fname=$1 [L,QSA]
RewriteRule ^blog/[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]

#index.php
RewriteRule ^.*?([^\.\/]*)\.html$ ?pname=$1 [L,QSA]
RewriteRule ^([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ ?d=$1$2$3 [L,QSA]
RewriteRule ^[^\.]*?([^/\.]*)/$ ?fname=$1 [L,QSA]
RewriteRule ^\w[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]
</IfModule>


Thanks again for the awesome support!
Hi,

The way Couch works, the name of the template always shows up in the URL (except for index.php). So for cloned-pages of blog, the URL will have 'blog' in it - which is what you see.

I think you have deviated a little from the tutorial -
going by the generated .htaccess file, I can see that you are using two templates (soundblog.php and blog.php) to create the blog section.

In the tutorial we used only a single template (blog.php) and that is what you'd need to do. The second template (soundblog.php) is superfluous.

I suspect you are confused about 'snippet' and 'template'.
I'm sure you wanted to use soundblog.php as a snippet but ended up making it a template.

Allow me to explain in short the difference between the two -
1. A template (as Couch understands it) is a PHP file that -
a. will carry the two PHP statements '<?php require_once( 'couch/cms.php' ); ?>' and '<?php COUCH::invoke(); ?>'
b. by virtue of the point 'a' above, it will appear in the admin-panel's sidebar
c. will carry the definitions for the editable regions
d. will be accessible from the front-end e.g. blog.php will be accessible as http://www.yoursite.com/blog.php
e. a corollary to the point above is that the name of the template will inevitably be a part of the URL accessing it

2. A 'snippet' on the other hand is a file that is supposed to carry only markup. This wile will *not* be accessible from the front-end, will *not* appear in admin-panel sidebar, will *not* define editable regions etc.

Take a look at the following example -
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Blog' clonable='1'>
    <cms:editable name='content' type='richtext' label='Content' />
</cms:template>

<cms:if k_is_page>
    <cms:embed 'single-blog-post.html' />
<cms:else/>
    <cms:embed 'list-blog-posts.html'/>
</cms:if>

<?php COUCH::invoke(); ?>

The code above is for a full-fledged template (say blog.php).
It will show up in admin-panel and be accessible from front-end.

The two snippets embedded within it ('single-blog-post.html' and 'list-blog-posts.html') will only carry markup code and, importantly, will never be accessed from the front-end.

So, if you use the pattern shown above your blog would be accessed as
http://www.yoursite.com/blog/ (list-view)
http://www.yoursite.com/blog/folder/post.html (page-view)

Notice how we are using a single template to show both a single post and a list of posts.

Does this help?
Yes! super helpful. Got everything working the way I want it now! Thanks again for the super fast and awesome support.
You are welcome :)
4 posts Page 1 of 1