At first I will explain what I need: I have a wordpress site and want to install a laravel system. After a lot of research saw that it was impossible to try to configure.htaccess so that the dos run in the same folder, so installed Laravel in a subdomain.
I don't have anything in wordpress that runs only with a subfolder (eg: www.dominio.com/folder or ** www.dominio.com/folder**/ ) just the root of the domain (index.php) and in the articles ( www.domain.com/999/title-title ).
My intention is for any url with a subfolder to be redirected to a subdomain ex.: "www.domain.com/folder" or "www.domain.com/folder/" go to "sub.domain.com.br"
However, this folder after the domain can be anything (not specific, using regex).
My current.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_URI} !(stories) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
</IfModule>
I can't define any condition that satisfies this, and reading other articles and docs the most logical thing I came up with was to add this (below), but it doesn't work. Surely the condition or perhaps previous conditions aren't generating an incorrect result... or it just doesn't work out the way I want.
RewriteCond %{REQUEST_URI}/(.*)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ https://sub.domain.com [L,R=301]
Thanks
Let's say you want to redirect www.domain.com/folder
directory to folder.domain.com
subdomain.
We can use the Apache rewrite rule to accomplish this.
RewriteEngine on
RewriteBase /
RewriteRule ^/folder/(.*)$ http://sub.example.com/$1 [R=301,L]
As you said you installed Laravel in a subdirectory you can try the option below which can be used to redirect /folder
to folder.domain.com
. This will work for both www.domain.com
and domain.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$
RewriteRule ^/?folder/(.*)$ http://folder.domain.com/$1 [R=301]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.