www to non-www with .htaccess

I currently have this .htaccess: pastebin.com/gfg5ujL0
On the bottom there are the lines to redirect http urls to https.
But if I go to my site using https :// www….. it will not redirect to non-www site.
It may cause a problem for Google I think.

Do you guys kindly know which is the line to add to make this redirect?
I searched a lot and each modify I apply makes my site offline! :(

Need help with URL redirection in .htaccess

I recently moved links from one directory to another. Rather than doing a Rewrite 301 for each and every link, I would like to do a single Rewrite, but I am clueless on how to make it work.

Sample OLD URLs:

/catalog/flurosenia/hn_4zk/hn4zk130.htm
/catalog/flurosenia/hn_4zk/hn4zkxcG.html

Sample NEW URLs:

/catalog/lily1000125/hn_5rp/hn5rp130.htm…

Need help with URL redirection in .htaccess

Reescrever URL’s com .htaccess mantendo hierarquia original dos arquivos e pastas

tenho uma dúvida referente a deixar as URL amigáveis para um site, creio que o título não está muito claro, mas seria o seguinte:

Estou fazendo uma manutenção em um site antigo em PHP, ele foi escrito de maneira com que as estruturas da página (header, menu lateral, conteúdo e rodapé) fossem divididas em arquivos separados. Então todas as páginas possuem um link para os outros arquivos de estrutura usando o include do PHP.

Acontece que todas as páginas foram criadas na raiz do site, ou seja, são mais 100 páginas que estão “jogadas” e eu gostaria de organizá-las melhor criando categorias, no caso de produtos. O problema é que eu queria fazer isso apenas reescrevendo a URL pelo htaccess, ainda assim mantendo as páginas na raiz pois dessa forma todos os arquivos e links externos já estão referenciado, ou seja, se eu criar subpastas eu perderia por exemplo as referências de scripts e estilos externos.


TL;DR

Gostaria de fazer algo como “categoria/produto/subproduto” alterando apenas a URL, sem necessariamente criar subpastas para isso. Senão eu perco as referência de arquivos externos (pois não compensa pra mim alterar um por um pois são muitos!)

Teria alguma solução para contornar esse problema?

Obrigado!

htaccess can’t force ‘friendly’ url

I have a small php mvc framework which runs on a droplet that uses ubuntu and i’m trying to make all the urls ‘friendly’. From:

index.php?u=controller/method/param 

To:

controller/method/param 

For that i’m using this .htaccess code:

Options -MultiViews RewriteEngine on  RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css) RewriteRule ^([^?]*) index.php?u=$  1 [L,QSA] 

With this i can make the url friendly but the unfriendly url is still there. Therefore i can access the same content both ways:

index.php?u=controller/method/param same as controller/method/param 

How do i force the url to always be friendly? No more index.php?u=?

Thank you!

Поддомены и htaccess

Нужно сделать так, что бы если пользователь зашёл на сайт через любой поддомен (у меня подключен wildcard), то отображалось содержимое site.ru/directory/

Типо чел переходит по subdomain.site.ru, но фактически он находится на site.ru/directory/

И код не должен конфликтовать с уже имеющимся

RewriteEngine on  RewriteCond %{REQUEST_FILENAME} !-f  RewriteRule ^(.*)/(.*)$   index.php?page=$  1&id=$  2 [L,QSA] 

файл .htaccess. Не работает

пытаюсь настроить работу файла .htaccess, но почему то он никаких изменений не вносит.

AddDefaultCharset UTF-8  RewriteRule ^contact?$   contact.php [NC,L] RewriteRule ^check?$   check.php [NC,L] RewriteRule ^404?$   404.php [NC,L]  ErrorDocument 404 /404.php 

Пишу вот так, и когда хочу перейти вместо contact.php на contact он мне выдает ошибку на хостинге…

Help with .htaccess setup to hide WordPress Directory

I have a WordPress site that is installed in a directory called cms.

I will be using a pure HTML page as my Home page, the inner pages will be using WordPress.

Let’s call the website mysite.com

visiting mysite.com needs to show my plain html page.

The help I need is to hide the cms folder in the URL.

I have the following .htaccess file in my root

<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^(www.)?netsitesworldwide.com$   RewriteCond %{REQUEST_URI} !^/cms/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$   /cms/$  1  </IfModule> 

And this .htaccess in side the cms directory:

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

I don’t think I need to have both but that is the only way I’ve gotten the pages to show up without an error.

For example lets say I have a page called MyPage

With how I have things set now it is accessible at:

mysite.com/MyPage AND mysite.com/cms/MyPage

I need it to only be accessible at mysite.com/MyPage

While maintaining the ability to serve the static HTML page at mysite.com

Any advice is appreciated!

Help with .htaccess setup to hide WordPress Directory

I have a WordPress site that is installed in a directory called cms.

I will be using a pure HTML page as my Home page, the inner pages will be using WordPress.

Let’s call the website mysite.com

visiting mysite.com needs to show my plain html page.

The help I need is to hide the cms folder in the URL.

I have the following .htaccess file in my root

<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^(www.)?netsitesworldwide.com$   RewriteCond %{REQUEST_URI} !^/cms/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$   /cms/$  1  </IfModule> 

And this .htaccess in side the cms directory:

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

I don’t think I need to have both but that is the only way I’ve gotten the pages to show up without an error.

For example lets say I have a page called MyPage

With how I have things set now it is accessible at:

mysite.com/MyPage AND mysite.com/cms/MyPage

I need it to only be accessible at mysite.com/MyPage

While maintaining the ability to serve the static HTML page at mysite.com

Any advice is appreciated!

Redirect all pages to homepage via .htaccess except backend

I’ve been trying to redirect all pages of my Magento website to homepage via .htaccess – except the backend, naturally. Currently, I’m using these rules and everything is working fine so far but I want to access my backend (domain.com/office):

# Redirect the all pages to homepage  RewriteEngine On RewriteCond %{REQUEST_URI} !/$   [NC] RewriteCond %{REQUEST_URI} !.(css|fonts|gif|jpe?g?|png|ico) [NC] RewriteRule ^(.*)$   / [R=302,L] 

Can someone help me with this? I’ve been trying many rules but none of them worked well. With some rules, when I try to access my backend, I’m still redirected to homepage. With other rules, I got a ERR_TOO_MANY_REDIRECTS error message.

Thanks!