w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How do I get .htaccess to redirect from wildcard subdomain page to wildcard subdomain folder
Add this to the htaccess file in your document root(s): RedirectMatch 301 ^/([^/]+).php$ /$1/ You'll most likely need that trailing slash because if it's redirecting you to a directory, mod_dir will redirect again in order to add the trailing slash. EDIT: To exclude, you'll have to use mod_rewrite: RewriteEngine On RewriteCond %{REQUEST_URI} !index.php RewriteRule ^/?([^/]+).php$ /$1/ [L,R=301]

Categories : PHP

htaccess redirect subdomain to folder and non-www to www
This works: RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ^domain.com$ RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^sub.domain.com$ RewriteRule ^(.*)$ http://www.domain.com/sub/$1 [R=301,L]

Categories : Htaccess

htaccess : virtual subdomain mapping to folder
try this (mod_proxy and mod_rewrite should be enabled): RewriteEngine on RewriteCond %{HTTP_HOST} !^www.domain.com$ RewriteCond %{HTTP_HOST} ^([^.]+).domain.com$ RewriteCond %{DOCUMENT_ROOT}/%1 -d RewriteRule ^ http://www.domain.com/%1%{REQUEST_URI} [P] RewriteCond %{HTTP_HOST} !^www.domain.com$ RewriteCond %{HTTP_HOST} ^([^.]+).domain.com$ RewriteCond %{DOCUMENT_ROOT}/%1 !-d RewriteRule .* - [R=404,L]

Categories : Htaccess

How to render a page on a WordPress website for a subdomain using htaccess
Try this: RewriteCond %{HTTP_HOST} !^(www). [NC] RewriteCond %{HTTP_HOST} ^(.*).example.com [NC] RewriteRule (.*) http://www.example.com/countries/%1/$1 [L] It will also redirect india.example.com/test.html to www.example.com/india/test.html

Categories : PHP

How do I redirect subdomain to subdirectory (with default folder) on htaccess without change address
If they are on the same server and have the same document root, then you really don't want to proxy at all. Remove the host part of the rule and get rid of the "P": RewriteEngine On RewriteCond %{REQUEST_URI} !^/sd_ RewriteCond %{HTTP_HOST} !^(www). [NC] RewriteCond %{HTTP_HOST} ^([^.]+).domain.com.br$ [NC] RewriteCond %{DOCUMENT_ROOT}/sd_%1%{REQUEST_URI} -f [OR] RewriteCond %{DOCUMENT_ROOT}/sd_%1%{REQUEST_URI} -d RewriteRule ^(.*)$ /sd_%1/$1 [L,NC,QSA] RewriteCond %{REQUEST_URI} !^/sd_ RewriteCond %{HTTP_HOST} ^www.([^.]+).domain.com.br$ [NC] RewriteCond %{DOCUMENT_ROOT}/sd_%1%{REQUEST_URI} -f [OR] RewriteCond %{DOCUMENT_ROOT}/sd_%1%{REQUEST_URI} -d RewriteRule ^(.*)$ /sd_%1/$1 [L,NC,QSA] #Rewrite for my Framework RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d R

Categories : Htaccess

create virtual subdomain from folder throught htaccess in shared hosting panel
I had the same issue before, you must use cpanel to create the subdomain. If I remember right there was a dns issue with this code: RewriteBase / RewriteCond %{HTTP_HOST} !^www.domain.com [NC] RewriteCond %{HTTP_HOST} ([^.]+).domain.com [NC] RewriteCond %{REQUEST_URI} !^/index [NC] RewriteRule ^(.*) http://domain.com/%1 [P] If you don't want to use cpanel creating wildcard domain entry such as *.domain.com should help.

Categories : PHP

forced https on subdomain .htaccess file is sending wordpress admin page to parent domain
Place the following in the .htaccess for the domain # .htaccess WildCard SSL + wordpress + subdomain RewriteEngine on RewriteCond %{HTTP_HOST} ^shop.domain.com$ RewriteCond %{REQUEST_URI} !^/shop/ RewriteRule ^(.*)$ /shop/$1 RewriteCond %{HTTP_HOST} ^shop.domain.com$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(/)?$ shop/index.php [L] # BEGIN WordPress for main domain <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ RewriteRule ^index.php$ - [L] RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress

Categories : Wordpress

Subdomain Points to Subfolder and need .Htaccess to Redirect to a Wordpress Multi-Site Sub-Site
Well, depending on your provider, you can point your subdomain towards the same directory of your top level domain, i.e.: example.com -> /public_html/ this.example.com -> /public_html/ But your question is not clear about what you are trying to do. Is it a subdomains network or is it a subfolders network? If subdomains, try to change the directory your subdomain points to as in the example above, and create the blog inside wp-admin/network/ If subfolders, then you don't need the subdomain, unless you really want to redirect it to a subfolder just like an easier to remember shortcut, in that case you don't need a RewriteRule, WP takes care of the virtual subfolder.

Categories : Wordpress

How to allow subdomain access but not folder access in Apache, htaccess?
OK I worked out what had cause the problem. It was this line # Default handler DirectoryIndex index.php Basically unless your directory uses a file called index.phpby default, the subdomain doesn't work. I commented this line. Another option would be to make sure all my index files had the .phpextension.

Categories : Htaccess

Avoiding Wordpress .htaccess rules on specific folder
You don't need multiple .htaccess you can put all the rules on the WordPress main .htaccess: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !^folder RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress Use either: RewriteRule ^folder/start.php$ /folder/index.php [R=301,L,NC] Or Redirect 301 /folder/start.php http://www.domain.com/folder/index.php Don't forget to change folder to your actual folder name.

Categories : Wordpress

.htaccess / mod_rewrite.c : CakePHP application in a subfolder where the root folder hosts a Wordpress installation
The following works for mydomain.com/cakeapp: (0) .htaccess in ROOT FOLDER #Action php /cgi-php52/php #AddHandler php52 .php # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^cakeapp/(.*)$ /cakeapp/$1 [L,QSA] RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress (1) .htaccess in the CAKEAPP-Folder <IfModule mod_rewrite.c> RewriteEngine on RewriteBase /cakeapp RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L] </IfModule> (2) .htaccess in the ROOT/CAKEAPP/APP-Folder <IfModule mod_rewrite.c> RewriteEngine on RewriteBase /cakeapp RewriteRule ^$ webroot/ [L] RewriteRule (.*) webroot/$

Categories : Wordpress

L4 and Wordpress - How to install L4 on subdomain shared with Wordpress
Try a structure like this: /home/user/www/wp -> Wordpress install /home/user/www -> Laravel install Make sure your home page goes to /home/user/www/public. Also, for readability, I recommend calling the Wordpress install folder blog.

Categories : Wordpress

htaccess for my subdomain
Usually the subdomain maps to a different host directory, thus you also need to add the .htaccess to that directory for it to work, also you may need to activate mod_rewrite on that directory maybe even on your virtual host level, just some pointers...

Categories : Htaccess

How to configure .htaccess for a subdomain?
".htaccess files provide a way to make configuration changes on a per-directory basis." http://httpd.apache.org/docs/2.2/howto/htaccess.html When a user fires a request in the browser, it walks all the way down: 1 server computer 2 apache service 3 (v)host configuration (via http.conf, which is preloaded into apache service) 4 directory configuration (which is loaded on demand) so, nope, you cannot configure vhosts in .htaccess, because it is out of reach if you have access to the http.conf or subsequent include files, just look at http://httpd.apache.org/docs/current/vhosts/examples.html

Categories : PHP

Redirect URL to a Subdomain by .htaccess
You don't need to turn the rewrite engine on, as the Redirect directive is part of mod_alias. You can add the other redirect before the one that redirects to xyz.com: Redirect 301 /blog/ http://blog.xyz.com/ Redirect 301 / http://xyz.com/

Categories : Htaccess

htaccess redirect where subdomain
I believe you don't have sufficient RewriteCond conditions for both redirects. What is happening is that first one is unconditional redirect and since it appears first it always fires and 2nd one never fires. Replace your code with this: Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] Above code will work with both of your domains.

Categories : Htaccess

htaccess non www to www and remove subdomain www
None of the rules you have in your question routes requests to a subdomain's folder. The /sub/ should never be there if it wasn't originally in the request. That said, all of your redirect rules need to come before any routing rules. Routing rules being stuff that internally routes requests to other URI's, for example: RewriteCond %{HTTP_HOST} ([^.]*).domain.com$ [NC] RewriteRule (.*) /%1/$1 [L] That rule internall routes to a folder named the same thing as the subdomain. If this rule were to be before the redirect, both rules get applied and the redirected URI becomes /sub/. You need your routing rules placed after your redirect rules, e.g. all rules that have a http:// or an R flag.

Categories : Htaccess

htaccess mod_rewrite subdomain
Add a trailing ? to your match to drop any query string present. RedirectMatch 301 ^/mobile/(.*)$ http://m.example.com/$1? Secondly, a RewriteCond does not apply to a RedirectMatch but a RewriteRule. RewriteCond %{QUERY_STRING} page=d+ [NC] RedirectRule ^mobile/(.*)$ http://m.example.com/$1? [R=301,L] [OR] was dropped because there's only one RewriteCond and [1-9]+ was changed to include 10 etc. Please note that putting a RewriteCond says that only redirect when you have page= in the query string. If you need the redirection regardless of that, drop the condition and just keep the rule.

Categories : Htaccess

How to create dynamic subdomain using PHP and htaccess?
You can't make dynamic subdomains with .htaccess You will need to configure the apache virtual host to accept requests for multiple domains See the Apache documentation - Using Name Based Virtual Hosts <VirtualHost *:80> ServerName www.example.com ServerAlias example.com *.example.com DocumentRoot /www/domain </VirtualHost> Adding the wildcard subdomain *.example.com, your PHP application will receive all requests for any domain below example.com, ie garbage.example.com, busted.example.com, llama.example.com, etc. Creating Wildcard Sub Domain Using Apache VirtualHost Multiple Domains to One Virtual Host | Wildcard Host (shared hosting)? Apache default virtual host for multiple domains At this point, your application will have to determine the validity of t

Categories : PHP

Use htaccess to redirect subdomain to a directory
You can use mod_rewrite for this: RewriteCond %{HTTP_HOST} ^shop. RewriteRule (.*) http://www.domain.com/shop/$1 [R=301,L] The RewriteCond checks to make sure that the hostname of the request begins with the string "shop." and if so, the subsequent RewriteRule is evaluated. The ^ before shop ensures that it only matches the string "shop" if it is at the beginning of the hostname.

Categories : Htaccess

.htaccess to remove https if subdomain of URL
You need a Wildcard SSL certificate to secure all sub-domains of website. Wildcard SSL certificates allow the management of multiple sub domains on a single domain with a single SSL certificate. If you don’t have or have a normal SSL certificate, then you can’t provide HTTPS to sub-domains, so I suggest you to buy a New Wildcard SSL certificate and then generate CSR (Code Signing Request) and install it on your server. If you are looking for cheap price, then buy it from the third party reseller. They are providing cheaper pricing then vendors. It’s my own experience. Third party reseller provides certificates from top brands with same quality.

Categories : Htaccess

htaccess ignore rewriterule for subdomain
Just add test in your negative RewriteCond like this: RewriteCond %{HTTP_HOST} !^(www|test). RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]

Categories : Htaccess

Remove www but do not affect subdomain (htaccess)
With (blog.)? at the begin blog. becomes optional and so it will redirect only if it is different from blog.mysite.com and mysite.com. RewriteCond %{HTTP_HOST} !^(blog.)?mysite.com$ [NC] RewriteRule ^(.*)$ http://mysite.com/$1 [L,R=301] A different way to do the same would be: RewriteCond %{HTTP_HOST} !^mysite.com$ [NC] RewriteCond %{HTTP_HOST} !^blog.mysite.com$ [NC] RewriteRule ^(.*)$ http://mysite.com/$1 [L,R=301] Which means if hostname is different then mysite.com and blog.mysite.com redirect. To avoid duplicity it is good to choose between www or non-www and redirect every thing for that. So if u use www then redirect non-www to www and vice versa.

Categories : Htaccess

.htaccess rewrite: subdomain as GET var and path as GET var
Use the first rule to add the subdomain parameter, without changing the URI, then use the 2nd rule to route the URI to index.php: RewriteEngine On # Parse the subdomain as a variable we can access in PHP, and # run the main index.php script RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{HTTP_HOST} !^www RewriteCond %{HTTP_HOST} ^([^.]+).([^.]+).([^.]+)$ RewriteRule ^(.*)$ /$1?subdomain=%1 # Map all requests to the 'path' get variable in index.php RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?path=$1 [L,QSA] The second rule needs to have the QSA flag, otherwise the first rule's query string gets lost.

Categories : PHP

.htaccess issue when trying to remove the www from subdomain
You are forgetting to keep the request uri. Use the following code (copied from somewhere; don't have the original source to give credit): <IfModule mod_rewrite.c> RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC] RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L] </IfModule> Edit: I suppose you have something like the following code in your .htaccess RewriteCond %{HTTP_HOST} ^(.*).calu.info$ RewriteRule ^(.*)$ http://%{HTTP_HOST}%1/$1 This needs to be removed

Categories : Htaccess

.htaccess, mod_rewrite and SSL subdomain redirects
Ok try this code: Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / #all the pages are sent to https if not already so with the #host name set to www.domain.com RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www. [NC] RewriteRule ^ https://www.domain.com%{REQUEST_URI} [R=301,L]

Categories : Htaccess

.HTACCESS Redirect No Subdomain To WWW and Keep The Rest
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory: Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^(website.com)$ [NC] RewriteRule ^ http://www.%1%{REQUEST_URI} [R=301,L]

Categories : Regex

.htaccess redirect codeigniter subdomain
I think you could easily "hack" your config/route.php file that way without even modifying your .htaccess : if ($_SERVER['SERVER_NAME'] == 'blog.mywebsite.com') { $route['default_controller'] = 'blog/home'; // Other routes to your blog } elseif ($_SERVER['SERVER_NAME'] == 'signup.mywebsite.com') { $route['default_controller'] = 'members/signup'; // Other routes for your signup }

Categories : Htaccess

Htaccess subdomain + multilingual website
the problem is that the url is Rewritten twice , the first time /sample-vg.html is rewritten correctly to ?sub=en&menu=ad&ad=fg, then in the second run the new url is been rewritten again to ?sub=en (L flag just stop the current run, not the entire process, take a look here) there is also a problem with the second RewriteRule(undefined %1), the following code should work as expected: RewriteBase / RewriteCond %{REQUEST_URI} ^/$ RewriteCond %{QUERY_STRING} !&ad=.* RewriteCond %{HTTP_HOST} ^([a-z]+).mywebsite.com$ [NC] RewriteRule ^(.*) ?sub=%1 [NC,L] RewriteCond %{HTTP_HOST} ^([a-z]+).mywebsite.com$ [NC] RewriteRule ^([-a-z0-9]+)-([A-Za-z0-9]+).html$ ?sub=%1&menu=ad&ad=$2 [L]

Categories : Htaccess

htaccess - redirect only non-subdomain requests
the solution is to add a condition that check if the host is domain.com before executing the RewriteRule RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ regarding your second question, one or more RewriteCond directives are not seperate instructions but associated with a RewriteRule, they are conditions that must be valid to execute the RewriteRule. in your case : RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !^/login/ RewriteRule ^([^/]+)/([^/]+)/?$ index.php?action=$1&urlId=$2 [L,QSA] the rewriteRule is executed only if the requested uri does not point to a file, and does not begin with /login/.

Categories : Apache

.htaccess in root not to interfere with subdomain rules?
You can add an additional condition and check only for "domain.com": RewriteCond %{HTTP_HOST} ^domain.com$ [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] or: RewriteCond %{HTTP_HOST} !^www. [NC] RewriteCond %{HTTP_HOST} ^[^.]+.[a-z]{2,4}$ [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Categories : Regex

.htaccess Redirect domain subdomain to sub directory
Redirect does not take a full domain as first argument, you have to use /: Redirect 301 / http://example.com/customerservice However if this domain is on the same root of another domain and you need to match the domain name you will have to use something like this: RewriteCond %{HTTP_HOST} ^customerservice.example.com$ RewriteRule ^(.*)$ http://example.com/customerservice/$1 [R=301,L]

Categories : Apache

.Htaccess - redirect subdomain to root domain
Try this code in your .htaccess under DOCUMENT_ROOT directory: Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$ [NC] RewriteRule ^$ shop/index.php [L] RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$ [NC] RewriteRule (?!^shop/)^(.+)$ /shop/$1 [L,NC]

Categories : Apache

Htaccess - redirect old site with variables to new subdomain
This should work RewriteEngine on RewriteBase / RewriteCond %{QUERY_STRING} language=french [NC] RewriteRule ^dir/.*$ http://dir.site.com/FR? [R=301,NC,L] RewriteRule ^dir/.*$ http://dir.site.com/EN? [R=301,NC,L] Redirects as follows http://site.com/dir/#/gallery/folder1/image1.jpg [OR] http://site.com/dir/?language=english#/gallery/folder1/image1.jpg => http://dir.site.com/EN#/gallery/folder1/image1.jpg http://site.com/dir/?language=french#/gallery/folder1/image1.jpg => http://dir.site.com/FR#/gallery/folder1/image1.jpg

Categories : HTML

My htaccess redirect rule is not working for my subdomain
Have you started the RewriteEngine? Make sure you have this somewhere before your .htaccess rules: RewriteEngine on RewriteBase / Without these, Apache's Rewrite engine won't recognize these rules, and won't start parsing them as you expect.

Categories : Htaccess

How to avoid having .htaccess redirects from applying to subdomain as well?
Change your code with something like this: # if subdomain then bail out RewriteCond %{HTTP_HOST} ^subdomain. [NC] RewriteRule ^ - [L] RewriteRule ^home.htm$ http://analystsolutions.com/ [L,NC,R=301] RewriteRule ^membersolutions.php$ http://analystsolutions.com/ [L,NC,R=301] RewriteRule ^institutionalsolutions.html$ http://analystsolutions.com/institutions [L,NC,R=301] # rest of your 301 rules here PS: Also make sure these rules are before WP code i.e. just below RewriteBase line.

Categories : Htaccess

.htaccess rewrite counteracts my subdomain pages
I don't think your regex for %{THE_REQUEST} is right. If you want, you can test it here: http://rubular.com/ I used this and it worked for me: RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s([^.]+).php [NC] RewriteRule ^ %1 [R=301,L] RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^ %{REQUEST_URI}.php [L]

Categories : PHP

htaccess: move traffic to www subdomain, so long as not cdn
Based on my reading of http://httpd.apache.org/docs/current/mod/mod_rewrite.html You can do: RewriteEngine on RewriteCond %{HTTP_HOST} !^(?:www|cdn|cdn1|cdn2).example.com RewriteRule (.*) http://www.example.com/$1 [R=301,L] This can be optimised a bit into: RewriteEngine on RewriteCond %{HTTP_HOST} !^(?:www|cdn[12]?).example.com RewriteRule (.*) http://www.example.com/$1 [R=301,L] I did not test this, so hope it helps.

Categories : Htaccess

Links on Subdomain broken after htaccess rewrite
Try this code : RewriteEngine on RewriteCond %{HTTP_HOST} ^www.(.*)$ RewriteRule ^(.*)$ http://%1/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^domain.com$ RewriteRule ^(.*)$ http://sub.domain.com/$1 [R=301,L]

Categories : Htaccess

Htaccess Virtual Subdomain not work properly
Just change your rule to: RewriteRule ^(.*)$ /%1/$1 [L] and add a condition to prevent looping: RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} -f [OR] RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} -d So you have: RewriteCond %{HTTP_HOST} !^www.mysite.* RewriteCond %{HTTP_HOST} ^([^.]+).mysite.* RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} -f [OR] RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} -d RewriteRule ^(.*)$ /%1/$1 [L]

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.