Redirect to parent folder on .htaccess - .htaccess

My Htdocs list folder
sofia (Laravel 5.2)
test1 (Laravel 5.2)
test2 (Laravel 5.2)
My URL Project is
https://localhost/sofia/public/login
how to edit my .htaccess
when type on my url
https://localhost
automatic redirect to https://localhost/login or https://localhost/sofia/public/login

Related

How set base dir in htaccess

I have my website with structure of
mywebsite
index.php
index_admin.php
By rewriting though .htaccess
www.mywebsite.com/home/main --converts--> mywebsite/index.php
www.mywebsite.com/home/admin --converts--> mywebsite/index_admin.php
this is working (hosted)
Now I tried it to run on localhost for dev purpose using XAMPP Linux
url
localhost/mywebsite/index.php launched but when logined and navigate to url /home/admin it become localhost/home/admin which does not found. I want it to become /localhost/mywebsite/home/admin so that correctly navigate to index_admin.php file

How to redirect non www to www for prod website

I've tried to add the item below in .htaccess(wamp64\bin\apache\apache2.4.37\conf) and enabled Use URL Rewriting in Joomla however when I try to type abc.com in search engine address bar it will still redirect me to search page instead of redirecting me to the website. I've also performed checking and confirmed that .htaccess file is readable, the webpage is work when go to https://www.abc.co m however redirection still not work. I just need the page to redirect from http://abc.co m to https://www.abc.co m Is there any other way to do it? Or I'm doing it wrongly?? Please help.
RewriteCond %{HTTP_HOST} ^abc.com [NC]
RewriteRule ^(.*)$ https://www.abc.co m/$1 [L,R=301]
The redirect itself works great. The issue is where you've put the file.
.htaccess files are meant to be in the root folder and sub-directories of your website, not in the config files for Apache. Think of them as configuration files the server will find on-the-fly as it serves up documents, not static configurations loaded when the server starts (which are found in the "conf" folder you referred to). (See https://httpd.apache.org/docs/current/howto/htaccess.html)
For WAMP, the root folder is typically a folder called "www" and is normally located at c:/wamp/www. See Where is the web server root directory in WAMP? More commonly, though, this folder is called "public_html" (such as with LAMP, XAMP, MAMP, or default Apache installs).

.htaccess: hiding subdomain with proxy redirect / rewrite

I need to access my site that sits in a subfolder from my domain.
The challenge - Due to my hosting structure, all sites are on the master domain's server in subfolders. Domains are mapped to those folders for each site. The master domain, however, is mapped to the server root like this -
• /www/ (root of www.masterdomain.com)
/folder 1/ (root of www.site1.com)
/folder 2/ (root of www.site2.com)
/folder 3/ (root of www.site3.com)
/folder 4/ (desired root of master domain)
If i install my CMS in folder 4 everything is fine, BUT the CMS code creates new assets in the server root (using DOCUMENT_ROOT i think), NOT in the subfolder.
Attempted fix 1:
Use a rewrite to remove subfolder and set all paths to include subfolder.
Failed - CMS acts as desired, but assets still created in the root.
Attempted fix 2:
Map a subdomain to the folder and rewrite URL to remove subdomain.
Failed: CMS works on subdomain and creates assets in the subfolder (win!), but can't rewrite a subdomain.
Attempted fix 3:
Map a subdomain to the folder, and use a proxy flag from the main domain to load content from it invisibly.
Progress made! Main homepage displays with the correct URL, however linked files and subfolders do not work.
So i can now reach my web app from:
app.exampledomain.com (app works perfectly on all fronts)
OR
exampledomain.com (proxy in effect, all subfolders and links broken)
Here's my htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# Proxy subfolders
RewriteRule ^exampledomain.com/(.+?)?$ http://app.exampledomain.com/$1 [P,L,NC]
# Proxy main
RewriteRule ^(exampledomain.com)?$ http://app.exampledomain.com/ [P,L,NC]
So why are my subfolders / assets not working? Problem with the .htaccess? Bad logic?
Important notes -
Subfolder pages are called index.php so can be accessed from -
/folder/
The broken links on the page are in this format -
js/foundation.min.js
Thanks.
RewriteRule knows nothing about domain names, it works only with a local path.
Instead, check the domain name in the RewriteCond:
RewriteCond %{HTTP_HOST} ^(www\.)*exampledomain\.com$ [NC]
RewriteRule (.*) http://httpd.apache.org/$1 [P,L]
But using mod_alias or VirtualHost would be a more correct decision here.

Htaccess Static Root And wordpress Subfolder

Hello i have static html site in the root folder ex: www.example.com . and WordPress site in sub-folder ex: www.example.com/blog so where to put htaccess file in root or subfolder. and how to configure single htaccess file to work for both site.
It depends on what you have in this htaccess file. If it's the Wordpress file, put it in the subfolder.
Anyway, you can have an htaccess file in both directory, the one in the subfolder will ovveride any file in parents directories.

Redirect wrongly mistyped URL to main domain

I need to Redirect my mistyped url into main domain ..
For example if user type mistyped.domain.com or domain.com/mistyped (which does not exists) .It should display the content of domain.com but the url in adress bar should be same as mistyped.domain.com or domain.com/mistyped
Note : I googled and tried some of the .htaccess but its just redirecting.The url in the adressbar is not samejust domain.com not mistyped.domain.com.
Below code worked
./mysite.com
dirs and folders
./m.mysite.com
drwxr-xr-x main_site -> ../mysite.com

Resources