htaccess: корневую директорию заменить другой

У нас 1 сайт site1.ru, и есть домен site2.ru который является синонимом первого домена. Т.е когда заходишь на site2.ru то видишь тоже самое что и на site1.ru.

Нужно сделать так, чтобы для при переходе по site2.ru, покатывался не корень сайта (т.е. /index.php), а по умолчанию подключалась папка /dev/index.php но при этом чтобы этот путь в адресной строке не отображался (т.е. только должен быть site2.ru).

Подскажите пожалуйста, как это сделать через htaccess ?

Redirect all pages form non-www to www with htaccess, but do not redirect subdomains

Before I start, I have read all of the related pages, and none have helped me.

To begin, I have a website which redirects non-www to www. This is fine, but I have subdomains that I do not want to be www.subdomain.example.com, I would prefer my subdomain to not have www in front. I still want the main page, example.com to be www.example.com. Trying other people’s code for this issue in .htaccess is not helpful to me. Could somebody look over my .htaccess? I don’t know what part even redirects.

    RewriteEngine On  RewriteCond %{SERVER_PORT} 80  RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$   RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$   RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)? RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$   RewriteRule ^(.*)$   https://jeffthecow.com/$  1 [R=301,L] <Files 403.shtml> order allow,deny allow from all </Files>  # secure .htaccess file <Files .htaccess>     Order allow,deny     Deny from all </Files>  # Deny access to filenames starting with dot(.) <FilesMatch "^\."> Order allow,deny Deny from all </FilesMatch>  # automatically corect simple speling erors <IfModule mod_speling.c>     CheckSpelling On </IfModule>  deny from 50.116.11.184 RewriteCond %{HTTP_HOST} ^jeffthecow\.sixlloyds\.com$   [OR] RewriteCond %{HTTP_HOST} ^www\.jeffthecow\.sixlloyds\.com$   RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$   RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$   RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)? RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$   RewriteRule ^(.*)$   "https\:\/\/jeffthecow\.com\/$  1" [R=301,L]  ErrorDocument 400 https://jeffthecow.com/error/400.html ErrorDocument 401 https://jeffthecow.com/error/401.html ErrorDocument 402 https://jeffthecow.com/error/402.html ErrorDocument 403 https://jeffthecow.com/error/403.html ErrorDocument 404 https://jeffthecow.com/error/404.html ErrorDocument 500 https://jeffthecow.com/error/500.html 

Thank you very much.

Excessão .htaccess redirecionamento de http para https

Olá, a minha dúvida é a seguinte:

Quero que todo o site seja redirecionado para .https, porém uma única pagina que está rodando um iframe .http não quero que seja redirecionada para https.

Com adicionar essa exceção? Tentei da seguinte forma:

RewriteEngine On      RewriteCond %{HTTPS} on     RewriteCond $  {REQUEST_URI} ^/medidorhtml?$       RewriteRule ^(.*)$   https://meusite.com.br/$  1 [R,L] 

Why is 301 Redirect Not Working After Removing .PHP Extension via HTACCESS?

I’m removing .php extension from files contained within a specific directory on my website (courses) via .htaccess on (Apache/2.2.26 (Unix)).

Additionally, I’d like to 301 redirect .php version to non-php version.

Old URL Structure:

http://www.example.com/courses/blue-course.php 

New URL Structure:

http://www.example.com/courses/blue-course 

My Current Issues:

non .php version of the pages are not 301 redirecting. both .php and non .php versions of the pages are viewable.

Here’s my code:

RewriteEngine On  # External Routing RewriteCond %{REQUEST_URI} (.*\/courses\/)([^\s]+)\.php [NC] RewriteRule (.*courses\/)([^\s]+)\.php http://www.example.com/$  1$  2 [L,R=301]  # Internal Routing RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^ %{REQUEST_URI}.php [L] 

habilitar .htaccess Apache Ubuntu

no he podido habilitar la reescritura en Apache

Hice lo siguiente

sudo a2enmod rewrite 

reinicie apache

sudo service apache2 restart 

como en el directorio var/www/html tengo varios sitios separados tengo uno especifico para una api que deseo implementar

var/www/html/site2/api 

luego configurar el apache

sudo nano /etc/apache2/sites-enabled/000-default.conf 

como lo quiero manejar desde un subdominio del tipo api.site2.com el virtualhost principal lo tengo asi

<VirtualHost *:80>     <Directory /var/www/html/site2>          Options Indexes FollowSymLinks MultiViews         AllowOverride All         Order allow,deny         allow from all      </Directory>      . . . </VirtualHost> <VirtualHost *:80>   ServerName api.site2.com   DocumentRoot /var/www/html/site2/api </VirtualHost> 

y desde luego le di su respectivo

sudo service apache2 restart 

después dentro del directorio /var/www/html/site2/api cree 2 cosas para probar

 - apples.html  - .htaccess 

en apples.html cualquier cosa que pueda visualizar pero en .htaccess puse lo siguiente

RewriteEngine on RewriteRule ^apples$   apples.html [NC] 

al entrar ah api.site2.com me arroja un error 404

que puede estar pasando? se me esta escapa algo?

Escaping chars in .htaccess

I can’t find proper list (or you need to be registered to some sort of forum or not clear list) of which chars should be escaped in .htaccess file. I found that dots don’t need to be escaped – but for me it’s irracional because they have meaning in “regex”.

For example this rewrite…

RewriteEngine On RewriteCond %{REQUEST_METHOD} POST RewriteCond %{REQUEST_URI} /index.php\/component\/users\/\?task=registration.register [NC] RewriteRule .* - [F,L] 

It has escaped all slashes which are not “beginning” but still that POST “pass through”

My question – does anyone have list which chars should be escaped?