skip to Main Content

I have main domain http://example.com on my root directory and all of my subdomains are in catalogs folder /catalogs/subdomain1,/catalogs/subdomain2.Currently my subdomain url in http://subdomain.example.com/index.php

I want to remove index.php from my subdomain.

My Root .htaccess file code is

<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect on https:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
  ErrorDocument 404 /index.php
</IfModule>

My Subdomain .htaccess

RewriteEngine on

# Redirect on https:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Options -Indexes

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php56” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php56 .php .php5 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

2

Answers


  1. Please use below code and update RewriteBase /root_directory/subdomain_folder_name/ at your .htaccess file.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /root_directory/subdomain_folder_name/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
    </IfModule>
    

    I hope this will helpful for you.

    Login or Signup to reply.
  2. Try this

    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} ^example.com$
    RewriteRule (.*) http://subdomain.example.com/$1 [R=301,L]
    RewriteRule ^$ folder [L]
    
    DirectoryIndex index.php
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search