Problem with redirection and subfolder

Hi everyone,

Here’s my problem. I’m a real noob concerning server issues.

I have my main website at the root of my server and I created a folder in order to host another website, running Kirby.
So, at first, it was possible to access this second website at the address mywebsite.com/mysecondwebsite/ by changing the RewriteBase in the .htaccess file to
> RewriteBase /mysecondwebsite

But now, I’ve bought a domain name for this second website and I want users to access this website through the address mysecondwebsite.com. I linked this domain name to my folder /mysecondwebsite but now, the website still work when I go to the address mywebsite.com/mysecondwebsite/ but I can’t figure out why the address mysecondwebsite.com brings me to an Internal Server Error.

If anyone understand my problem and can help me, I would be very thankful !

Have you commented out the RewriteBase again?

If not, it should now either look like this

#RewriteBase /something

or this

RewriteBase /

depending on your server settings.

I tried both and nothing works. Or at least when I have

#RewriteBase /something

I can access the website through the adress mywebsite.com/mysecondwebsite but not with mysecondwebsite.com.

You could try to set the URL in your config.php

c::set('url', 'http://yourdomain.com');
1 Like

So, it’s better but still weird.
The website is still impossible to access through mywebsite.com but the link www.mywebsite.com is working.
Then, if I try to access any subpage, I got an Internal Server Error, but the link is working when I add index.php into it (for example, mywebsite.com/index.php/subpage)
The panel is still not working.

What does your .htaccess look like now? Have you set the RewriteBase?

If that does not work, make sure that mod_rewrite is enabled.

# Kirby .htaccess

# rewrite rules
<IfModule mod_rewrite.c>

# enable awesome urls. i.e.:
# http://yourdomain.com/about-us/team
RewriteEngine on

# make sure to set the RewriteBase correctly
# if you are running the site in a subfolder.
# Otherwise links or the entire site will break.
#
# If your homepage is http://yourdomain.com/mysite
# Set the RewriteBase to:

RewriteBase /tipotetik_beta

# block text files in the content folder from being accessed directly
RewriteRule ^content/(.*)\.(txt|md|mdown)$ index.php [L]

# block all files in the site folder from being accessed directly
RewriteRule ^site/(.*) index.php [L]

# block all files in the kirby folder from being accessed directly
RewriteRule ^kirby/(.*) index.php [L]

# make panel links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^panel/(.*) panel/index.php [L]

# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]

</IfModule>

# Additional recommended values
# Remove comments for those you want to use.
#
# AddDefaultCharset UTF-8
#
# php_flag short_open_tag on

Here’s my .htaccess file. How can I make sure that my mod_rewrite is enabled ?

You RewriteBase should be either commented out or set to the root, as explained above, because from the perspective of the domain, your project is not located in a subfolder.

You can check if mod_rewrite is enabled by creating a php file in the root directory , e.g. info.php with the following content

<?php
phpinfo();

and then call that file.

Ok, that’s probably where my problem comes from. I don’t find anywhere mod_rewrite in my info.php…

The strange thing is you said above your website worked when calling it like this:

So, at first, it was possible to access this second website at the address mywebsite.com/mysecondwebsite/ by changing the RewriteBase in the .htaccess file to

RewriteBase /mysecondwebsite

But did the panel and subfolders work then?

In fact, I’ve just tried different things. And now I’m almost done with that. Subpages and Panel work, homepage works when I have the address www.mywebsite.com, the last thing that doesn’t is the homepage with the link mywebsite.com

Here’s my .htaccess now

# Kirby .htaccess

# rewrite rules
<IfModule mod_rewrite.c>

Options +FollowSymLinks

# enable awesome urls. i.e.:
# http://yourdomain.com/about-us/team
RewriteEngine on

# make sure to set the RewriteBase correctly
# if you are running the site in a subfolder.
# Otherwise links or the entire site will break.
#
# If your homepage is http://yourdomain.com/mysite
# Set the RewriteBase to:

RewriteBase /

# block text files in the content folder from being accessed directly
RewriteRule ^content/(.*)\.(txt|md|mdown)$ index.php [L]

# block all files in the site folder from being accessed directly
RewriteRule ^site/(.*) index.php [L]

# block all files in the kirby folder from being accessed directly
RewriteRule ^kirby/(.*) index.php [L]

# make panel links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^panel/(.*) panel/index.php [L]

# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]

</IfModule>

# Additional recommended values
# Remove comments for those you want to use.
#
# AddDefaultCharset UTF-8
#
# php_flag short_open_tag on

Have you pointed your domain without www to the same folder? Nevertheless you should decide which domain name you want to use for the website (either with or without www) and then redirect the one to the other, so as to prevent duplicate content.

Check out this repo for the appropriate .htaccess rules: https://github.com/jenstornell/kirby-htaccess-rules

That works !
Thank you so much for your help !

You are welcome. Glad we sorted it out.:slight_smile: