Forum for discussing general topics related to Couch.
7 posts Page 1 of 1
Hi

I am having a nightmare with seo urls, couchcms and htaccess file

it works apart from every time I go to a page called gallery and go to another page, it seems to think that the other pages are in a folder called gallery and the link is all wrong and keeps saying page not found

can someone please help me as this is frustrating me now
My htaccess that is located in the root of the website not the couchcms folder is below

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]

## don't touch /cms URIs
RewriteRule ^cms/ - [L,NC]

RewriteRule ^(photobooths-for-hire-essex)$ "$1/" [R=301,L,QSA]
RewriteRule ^(photobooths-for-hire-essex)/$ $1.php [L,QSA]

RewriteRule ^(contact-us)$ "$1/" [R=301,L,QSA]
RewriteRule ^(contact-us)/$ $1.php [L,QSA]

RewriteRule ^(sitemap)$ "$1/" [R=301,L,QSA]
RewriteRule ^(sitemap)/$ $1.php [L,QSA]

#DO NOT EDIT BELOW THIS

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

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

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

UPDATE: Sorry noticed it's not when am just in the gallery page, it's on all pages so thinking something can't be right with my htaccess file or could it be the config file, I can attach the config.php file if needed?

Thank you in advance

Ian
The way to resolve your issues is the following:
1. Make sure correct linking is used inside your code. Basically, you should never hardcode any links. Use <cms:link /> tag all the time.
2. Any resources, css, js urls should use variable k_site_link. Sample: <img src="<cms:show k_site_link />images/01.jpg" />
3. Generate htaccess with /couch/gen_htaccess.php and place it in root. Don't edit it unless you don't know what you are doing. On this step you don't have pretty-urls enabled, but all pages in your website should work as normal and show up. Htaccess is already placed in root, but doesn't interfere yet.
4. Enable pretty-urls. Now your htaccess rules are in game.

Now, do your links work as normal on step 3?
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
All my links now look like the following structure

Code: Select all
<cms:show k_site_link />contact-us">Contact Us</a>


the links are still not correct so will try generating a htaccess file again and see if that works

in the config file, the pretty urls are already enabled

I have gone to generate the htaccess file using gen_htaccess.php file but all I get is a blank white page?
ianhaney50 wrote: All my links now look like the following structure

Code: Select all
<cms:show k_site_link />contact-us">Contact Us</a>


the links are still not correct so will try generating a htaccess file again and see if that works

in the config file, the pretty urls are already enabled

I have gone to generate the htaccess file using gen_htaccess.php file but all I get is a blank white page?

The structure is wrong. You seem to have missed what I said: k_site_link is used for resources. Interpage/intertemplate links should always be written with cms:link. Correct this as a first step.

Next, turn off pretty-urls and make sure your links are working. Next, generate htaccess and check again that links are working. Only after confirming all of that, enable pretty-urls as the very last step.

You might need someone to help you follow all the routines and instructions.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
I have done all the steps and only issue I found is the footer links are wrong apart from home and photobooths, the rest seem to be be going to the same place

the coding in the footer.php looks like the following

Code: Select all
<a href="<cms:link 'index.php' />">Home</a> | <a href="<cms:link 'what-we-do' />">What We Do</a> | <a href="<cms:link 'photobooths-for-hire-essex.php' />">Photobooths</a> | <a href="<cms:link 'packages-and-prices' />">Packages and Prices</a> | <a href="<cms:link 'sweet-list' />">Sweet List</a> | <a href="<cms:link 'gallery' />">Gallery</a> | <a href="<cms:link 'contact-us' />">Contact Us</a> | <a href="<cms:link 'sitemap' />">Sitemap</a>


the site link is http://www.sweetzandtreatz.co.uk
Stopped reading after this:
<cms:link 'packages-and-prices' />

Can you, please, explain what are you trying to do?
I guess, it's time to read again documentation for cms:link tag.
http://docs.couchcms.com/tags-reference.html

Why do we pay so much attention to it?
You see, if we let Couch look for our pages and templates,
creating a correct link every time - we save ourselves a lot of troubleshooting.

For example, page can be moved from one folder to another, pretty urls
can be changed, website can be moved to another domain, website can be placed in a subdirectory - those are the normal causes of pain with links. Before Couch
we must edit code directly all the time in case of major/minor changes.

With Couch (long live @KK), we don't have to spend our precious time for it.
If links are properly coded as per documentation, then everything is taken care of.
That's why it might save some time for you too! Enjoy the power of good code,
make things right all the time ;)
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
So sorry have got it sorted now
7 posts Page 1 of 1