adasdasd adasdasd - 2 years ago 138
Apache Configuration Question

.htaccess folder/subdomain rewrite rule

I am going through a strange behaviour of .htaccess.

I am writing a rule of .htaccess to convert the below url :

I want to convert the following URL (where

is variable.)


Note that
is generated at runtime. (Created by user)

But my rule is not working.


Options +FollowSymLinks
RewriteEngine On

RewriteBase /

RewriteCond %{HTTP_HOST} !$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+) [NC]
RewriteRule (.*) nono.html?sm=%2 [NC,QSA]

Answer Source

I got your issue.

your re-write rule is just opposite..

use this for your exact problem

and it will work

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST}%{REQUEST_URI}   ^(www\.)?$(.*)
RewriteRule  (.*)  https://$  [L]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download