promembers tk
promembers tk

Reputation: 1

htaccess file edit to use laravel and php website same time

my shared hosting space file arrangement as below

#root > public_html > [extracted laravel public folder]
#root > public_html > Project1 > [php project file]
#root > public_html > Project2 > [wordpress project file]
#root [Laravel project rest of the files]
#root > public_html > .htaccess file

I need to show pages as below

www.domain.com [laravel project]
www.domain.com/contact [same laravel project contact us page]
www.domain.com/project1 [php new project]
www.domain.com/project2 [wordpress website project]

to make this work i need to edit root > public_html > .htaccess file but i don't know how to do it . here is my current file. can you help me to fix this

   ##############.htaccess file #################
    <IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On
     RewriteRule ^project1 /project1/index.php [L]
    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    </IfModule>

Upvotes: 0

Views: 294

Answers (1)

Thakkie
Thakkie

Reputation: 579

The information you provided is a bit lacking, but here is to solution for my best guess of what you are asking.

##############.htaccess file #################
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews -Indexes
</IfModule>

RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Redirect all requests to ^/project-1/.* to the WordPress front controller
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/project-1/
RewriteRule ^ /project-2/index.php [L]

# Assuming your new PHP project also has a front controller 
# Redirect all requests to ^/project-2/.* to the new PHP project front controller
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/project-2/
RewriteRule ^ /project-2/index.php [L]


#Redirect all requests to ^/.*, but not ^/project-1/.* and not ^/project-2/.*
# to the Laravel front controller
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/project-1/
RewriteCond %{REQUEST_URI} !^/project-2/
RewriteRule ^ index.php [L]
</IfModule>

Upvotes: 1

Related Questions