Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
Hello all. I have a question about manipulating the .htaccess file generated from couchcms...

First of all, I have created a website for a client (not posting URL for security reasons), and there are many clonable pages within the website. There is a clonable template page.php that handles the websites "pages", and populates the navigation menu. I've been learning more and more about CouchCMS, and I recently realized there are some things I could have done differently when creating this website... I did not use index.php as the clonable template for my "page creator", and I think could have utilized custom routes for the home/landing pages having used index.php.

With that said, I'm searching for a way to further simplify the page URLs for the website. With Pretty URLs activated, each of the pages created from the page.php template has a URL like this: /page/admissions/tuition-fees.html. I'm trying to remove the 'page/' part of those URLs.

I want to know if I can edit the following section of the Couch generated .htaccess file...

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

If I just delete the "page/" text after ^, will that mask the template name in the URL? Would look like this...

#page.php
RewriteRule ^$ "$0/" [R=301,L,QSA]
RewriteRule ^$ page.php [L,QSA]
RewriteRule ^.*?([^\.\/]*)\.html$ page.php?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])/)?)?$ page.php?d=$1$2$3 [L,QSA]
RewriteRule ^[^\.]*?([^/\.]*)/$ page.php?fname=$1 [L,QSA]
RewriteRule ^[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]

Not sure if it's that simple of a fix or not. Not something I want to go messing with without getting some help. Measure twice, cut once.

I also want to know if I can remove the .html part at the end.


Sam
WorthDesignCo.com
Hi, take a look at this explanation about folders, templates and pages. You'll find also how to remove .html from the end. viewtopic.php?f=4&t=10313#p25114
Hi Trendoman. Thanks for your reply. At this point in the project, that seems it would take a complete rebuild of the website. This is a college website and they cannot afford any downtime. Also, due to the complexity of the website structure, I'm not certain if nested pages or custom routes would solve my issue or not. I was wondering if I can get PrettyURLs to help any at this point by editing the .htaccess file created from couch. Thanks again for your information.


Sam
WorthDesignCo.com
I think it's better to leave couch-generated code as is if you already use pretty-urls.

If you think for a moment, you'd want to write a separate rule somewhere closer to top in htaccess, to make sure your page gets correctly redirected before any couch rule for pretty urls gets into consideration.

As a free advice, recreate the sample template in localhost and make some pages and test how things work for you. A great tool for testing rules is https://regex101.com/#pcre
Thanks for your help Trendoman. I will look into regular expressions more, but it is sounding best to leave .htaccess how it is for now. I think, the more I read about it, my situation may have been avoided by using nested pages and custom routes.

Thanks again.


Sam
WorthDesignCo.com
5 posts Page 1 of 1