I have root project with 3 folders :
api
admin
frontend
on my root my .htaccess is :
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/frontend/dist/
RewriteRule ^(.*)$ /frontend/dist/$1 [NC,L]
My front is live with no problems, but i can't access to my admin, so i tried :
RewriteEngine on
RewriteRule ^(admin)($|/) - [L]
RewriteCond %{REQUEST_URI} !^/frontend/dist/
RewriteRule ^(.*)$ /frontend/dist/$1 [NC,L]
But unfortunately, it doesn't work. I have to access to https://localhost:8000/admin/xxx
If someone can help me :) thanks a lot and have a nice day
Related
I could do with some assistance trying to clean up an .htaccess file that has been running on one of our servers at work.
It is currently set up so that if someone types example.com it will redirect to www.example.com. The problem is that we want to utilise subdomains but when we try to add a subdomain, like beta.example.com it will redirect to www.beta.example.com
Here is the .htaccess file
DirectoryIndex index.html index.php
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
I have tried multiple variations from questions here on SO and via Google and htaccess generators and none of them seem to help as they usually put the site in a redirect loop.
Any help on getting the configuration correct would be appreciated.
-- Chris
To automatically add a www to your domain name when there isn't a subdomain, add this to the htaccess file in your document root::RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
Hello I'm trying to redirect /fr/welterweight.php which is a local folder on my website via apache conf or .htaccess.
To http://www.bluek.com/fr/welterweight.php?c=france which is another website I own.
I tried
RewriteCond %{REQUEST_URI} /fr/welterweight.php
RewriteCond %{QUERY_STRING} ^welterweight.php$
RewriteRule ^/?$ http://www.bluek.com/fr/welterweight.php?c=france
But its not working
This rule should work from site root .htaccess:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^fr/welterweight\.php$ http://www.bluek.com/$0?c=france [L,R=302]
I've got the root of my domain with some folders.
app
scripts
shop
And I want to redirect with the .htaccess everything to the folder shop, except app and scripts. I wrote the next .htaccess, but I've got a 500 ERROR INTERNAL SERVER. I saw the log file and it says that there is and endless loop.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/app
RewriteCond %{REQUEST_URI} !^/scripts
RewriteRule (.*)$ shop/$1 [L]
I have another hosting with other apps and cms in the same hosting provider. Even with the same structure and it works perfect, then I don't undertand why doesn't work here.
How can I avoid the endless loop?
EDIT: I want that the redirect will be invisible, not with [R]
EDIT 2: My purpose is:
Having this folders:
app
scripts
shop
Access to the shop folder with the URL: domain.com
Access to the app folder with: domain.com/app
Access to the scripts folder with: domain.com/scripts
You'll also have to exclude URLs beginning with shop:
RewriteEngine On
RewriteRule ^/?$ /shop/ [L]
RewriteCond %{THE_REQUEST} ^GET\ /shop(/\S*)? [NC]
RewriteRule ^shop / [R=301,L,NC]
RewriteCond %{REQUEST_URI} !^/(app|scripts|shop)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /shop/$1 [L]
I've been trying this for a while. I want to redirect for example wwww.example.com to exmaple.com.
I've tried several snippets of code:
RewriteCond %{http_host} ^dansams\.co.uk [nc]
RewriteRule ^(.*)$ http://www.dansams.co.uk/$1 [R=permanent,nc,L]
....
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
There are more but none have worked. I have my .htaccess file in the root along with a folder called 'public_html'. All of my sites content is within that public_html folder. What's happening when I've tried all these different snippets of code, is when I try www.example.com, it's getting taken to the url:
www.example.com/public_html
This page displays some content but without css...and it's not all the index content either.
Any help with this would be highly appreciated.
Thanks in advance
Try this:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
ok i am having a problem with redirection on apache, i have a domain configured on my hosting account but the domain needs to be redirected to a folder. eg: / is root of server where the mysite.com answers /mysite is where the files are so i got this htaccess code to do the job:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteCond %{REQUEST_URI} !^/mysite/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /mysite/$1
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^(/)?$ mysite/index.php [L]
plus i made an index.php to redirect to mysite folder.
everything seems to be working good the only problem is i added a forum on /mysite/forums/
and for some reason instead of getting mysite.com/forums/ in the browser im getting mysite.com/mysite/forums/
could anyone help me solve this problem?
Thanks in advance!
I would try writing the full address, so something like:
RewriteRule ^(.*)$ http://www.site.com/$1
and
RewriteRule ^(/)?$ http://www.site.com/index.php [L]
ok i got what was wrong and i thank everyone that had a look at it.
Solution:
Change last line
RewriteRule ^(/)?$ mysite/index.php [L]
to
RewriteRule ^(/)?$ mysite/$1 [L]
so it answer to anything coming from that folder not just the index.php :)