Search code examples
mysqlwordpress.htaccessputty

Getting the subdomain URL for wordpress within Laravel project in PuTTy SSH


Not sure if this question was asked before but I've tried a few answers given within stack to resolve the setting up of a wordpress subdomain within a laravel project with no avail.

I have a folder structure set in puTTy as per

laravel project

app

config

public

.htaccess

resources

.env

...

wordpress

wp-config.php

wp-content

wp-includes

.htaccess

the laravel project is running fine but I want to add wordpress as a subdomain e.g. laravel.com/wordpress

on laravel .htaccess I've added a new line RewriteCond %{REQUEST_URI} !^/wordpress[NC]

and on wordpress's .htaccess with it's standard

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /laravel.com/wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /laravel.com/wordpress/index.php [L]
</IfModule>

# END WordPress

i've also updated the database wp-option to set the url to http://laravel.com/wordpress on both the siteurl and home

however while expecting to be able to access the site locally via localhost/laravel/wordpress (it works) but on the live server laravel.com/wordpress it returns a 404 page.


Solution

  • I have fixed the issue by adding a new rewrite condition in the public level

    RewriteCond %{REQUEST_URI} !^/wordpress[NC]
    RewriteRule ^(.*)/$ /$1 [L,R=301]
    

    which solved the issue of the page returning a 404 and showing my wordpress page just fine