Problems, need help? Have a tip or advice? Post it here.
7 posts Page 1 of 1
Hello,

I have activated Pretty URLs and generated a new .htaccess-file but unfortunately it doesn't work with every page.
I'm working with xampp and the .htaccess file is located in the root. My page is in a subfolder.

I have two php files where I have inserted couchcms tags: index.php and content.php.
Both templates are clonable and both files are located in the same subfolder.
Index.php is working with Pretty URLs but content.php isn't working!
I tried it with different php-files as well but it only works with the index.php.

So when I call the page "http://localhost/mysubfolder/content.php?p=3" it get's redirected to "http://localhost/mysubfolder/content/about-us.html" but the page shows:
"Page not found".

This is how my .htaccess looks like:

Code: Select all
Options +Indexes +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 /mysubfolder

#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]

#content.php
RewriteRule ^content$ "$0/" [R=301,L,QSA]
RewriteRule ^content/$ content.php [L,QSA]
RewriteRule ^content/.*?([^\.\/]*)\.html$ content.php?pname=$1 [L,QSA]
RewriteRule ^content/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ content.php?d=$1$2$3 [L,QSA]
RewriteRule ^content/[^\.]*?([^/\.]*)/$ content.php?fname=$1 [L,QSA]
RewriteRule ^content/[^\.]*?([^/\.]*)$ "$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>
If you move the .htaccess file to the subfolder it should work just fine. I have my local wamp server working this way.
If you move the .htaccess file to the subfolder it should work just fine. I have my local wamp server working this way.


Thanks for your help! Ok when I move the .htaccess in the subfolder at least all pages get loaded. But unfortunately all image, css and javascript files that are implemented with a relative path (like src="js/default.js") won't get loaded!
because it seems that the browser now thinks that the file is located in "http://mysite/mysubfolder/content/js/default.js" if the name of the page is content.php.
But the real path is "http://mysite/mysubfolder/js/default.js"
What can I do?
Hi MGMT,

That is a problem you'll encounter anytime you use mod_rewrite - relative paths won't work.
For sites that are not in subfolder you can get away be prefixing the links with a '/'
e.g.
Code: Select all
src="js/default.js"

should be made
Code: Select all
src="/js/default.js"

In your case you'll have to explicitly prepend the full path like this
Code: Select all
src="<cms:show k_site_link />js/default.js"

This way your code become 'future-proof' - you can safely move the files anywhere and the link will come out right.

Hope this helps.
Thank you so much for all of your help KK.
Now it's working!
You are welcome MGMT :)
Enabling prettyURLs is throwing me an error, I'm suspecting it's my .htaccess file as it has other lines of code in it, but I have failed to pinpoint the issue.
mydomain.com/prettyURL is not working, but mydomain.com/prettyURL/page/ works.

If i am clicking on about page form contact page, it is opening like mydomain.com/contact/about/. how to solve this
7 posts Page 1 of 1
cron