Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
2 posts Page 1 of 1
Problem: I want the url to look like http://www.mysite.com/articles/news/art-name and not http://www.mysite.com/articles/news/newscms/art-name.html (the added "newscms" is because I have an index file in the directory http://www.mysite.com/articles/news that isn't the template file.

Solution:

Don't use pretty urls in Couch

Create a .htaccess file in your root directory with the following code

Code: Select all
RewriteEngine On

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.mysite\.com$ [NC]
RewriteRule ^(.*)$ https://www.mysite.com/$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php


Create a .htaccess file in the /news directory

Code: Select all
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ newscms.php?pname=$1 [NC]


repeat the code snippet above for each cloneable template :D
Thank you for posting this solution.

Alternatively, you can have an 'articles.php' template in site's root with a folder 'news' and all cloned pages of that template will take a pretty url form as 'http://www.mysite.com/articles/news/art-name.html'.

Also, nested-pages type of template doesn't have '.html' added to the pretty url form.
2 posts Page 1 of 1