I’m here once again to try to understand something.
I’m having problems creating a subdomain.
Enforce subdomain ownership was disabled, as I saw in a post here in the community.
I created the domain domain.com and added the subdomain app.domain.com and activated the Custom Document Root pointing to the “app” directory that exists in /home/user/web/domain.com/public_html/app
There is no .htaccess in this directory, but I still get this error
[Sat Feb 01 20:50:34.414505 2025] [core:alert] [pid 88500:tid 88544] [client xxx.xxx.xxx.xxx:0] /home/user/web/domain.com/public_html/.htaccess: <IfModule not allowed here, referer: https://app.domain.com/
Can you provide a detailed description? What problem have you encountered? Why should it be in the public_ html/app directory instead of the public_ html directory? The public_tml directory is the root directory of the website.
I wasn’t very clear when I said that the directory doesn’t have .htaccess. In fact, it only exists in the public root directory. Inside the app directory, there is no .htaccess
[Sat Feb 01 20:50:34.414505 2025] [core:alert] [pid 88500:tid 88544] [client xxx.xxx.xxx.xxx:0] /home/user/web/domain.com/public_html/.htaccess: <IfModule not allowed here, referer: https://app.domain.com/
If I delete the .htaccess, pointing to the app directory works perfectly, but I need the .htaccess with the friendly URL rules inside the public_html root directory.
The error message you are receiving indicates that the <IfModule> directive is not allowed in the context where it is currently placed in your .htaccess file. This is usually because the Apache configuration does not allow such directives within .htaccess files, or the server configuration might be limiting the use of <IfModule> to specific sections.
Here are a few steps to troubleshoot and potentially solve your issue:
Remove <IfModule> Tags:
Since you are encountering issues with <IfModule>, try removing these tags from your .htaccess file. This assumes that mod_rewrite is indeed enabled on your server, which is typically required for the rewrite rules to work.
Note: The commented out RewriteCond lines were checking if the requested file exists and is a regular file, a symbolic link, or a directory. If you uncomment these, they ensure that the rewrite rules only apply if the file does not exist (this is a common practice to avoid rewrite loops). However, since you mentioned removing .htaccess from the app directory solved issues, it might not be necessary in your specific use case.
Ensure mod_rewrite is Enabled:
Contact your hosting provider or check your server’s Apache configuration to ensure that mod_rewrite is enabled. This is crucial for rewrite rules to work.
VirtualHost Configuration:
If you have access to the Apache VirtualHost configuration, you can place the rewrite rules there instead of in .htaccess. This is generally more efficient and avoids some limitations of .htaccess files.
Note: Adjust the paths and configuration as necessary.
Test Configuration:
After making any changes, restart your Apache server to apply the new configuration. Test your site to ensure that the rewrite rules are working as expected.
By following these steps, you should be able to resolve the issue with your .htaccess file and get your rewrite rules working correctly for both the root domain and the subdomain.
Hello yonli!
I think you are not understanding correctly because you are using a translator to write in English, as my language is Brazilian Portuguese.
The reason for the subdomain is that:
Subdomain app.domain.com shows the page of the directory /public_html/app/
Main domain domain.com shows the page of the root directory /public_html/
I removed the <IfModule> tag and commented out RewriteRule inside .htaccess leaving it as in your example, I received the following error and it gave me the impression that for the pointing to work I cannot use url writing rules.
[Sun Feb 02 19:43:35.401266 2025] [core:alert] [pid 332851:tid 332865] [client xxx.xxx.xxx.xxx:0] /home/user/web/domain.com/public_html/.htaccess: RewriteRule not allowed here, referer: https://app.domain.com/
If I make the change in virtualhost as suggested by you, both the main domain and subdomain would point to the same public_html directory, which is not what I need.
If I remove the .htaccess from public_html and put the writing rules in virtualhost, the url writing does not work.
Consegui fazer funcionar como preciso criando registro CNAME no DNS ao invez de criar subdominio e adicionando essa regra no .htaccess