Posts

Showing posts from February, 2022

Use .htaccess to configure subdomains serve content from folders rather than from the root domain

Use .htaccess to configure subdomains serve content from folders rather than from the root domain - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, subdomain, multiple-domains, , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : Here is site http://www.glassnow.com.au/ With 3 subdomains: brisbane.glassnow.com.au goldcoast.glassnow.com.au sunshinecoast.glassnow.com.au Here is htaccess RewriteEngine On RewriteBase / RewriteCond %HTTP_HOST ^www.glassnow.com.au RewriteRule ^brisbane/(.*)$ http://brisbane.glassnow.com.au/$1 [L...

.htaccess to redirect domain1 to domain2

.htaccess to redirect domain1 to domain2 - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about domains, htaccess, mod-rewrite, multiple-domains, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I currently have a .htaccess file with the current lines to force HTTPS: RewriteEngine On RewriteCond %HTTPS off RewriteRule ^(.*)$ https://%HTTP_HOST%REQUEST_URI [L,R=301] My main domain is example.com I have a registered an alias in my cPanel: example.net I would like to implement a rule so that if a user visits example.com , they will be re...

example.com to www.example.com .htaccess redirect working except one subdir

example.com to www.example.com .htaccess redirect working except one subdir - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about apache, htaccess, redirects, 301-redirect, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I've setup a redirect in .htaccess to consolidate example.com to www.example.com traffic on our Apache server. Looks like this: Options +FollowSymLinks RewriteEngine On RewriteCond %HTTP_HOST ^centerline.net$ [NC] RewriteRule ^(.*)$ http://www.centerline.net/$1 [R=301,L] Works as expected, except for the blog....

How can I redirect example.com/username to Instagram app directly open from deep link?

How can I redirect example.com/username to Instagram app directly open from deep link? - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, redirects, apache, apache2, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I'm trying to redirect from example.com/username​ to Instagram deep link instagram://user?username=anyusername Here is my htaccess code RewriteEngine On RewriteBase / RewriteCond %HTTP_HOST ^(www.)? example.com$ [NC] RewriteRule ^ instagram://user?username=%REQUEST_URI [R=301,L,NE] But it redirects to http...

.htaccess and permanent redirection issues

.htaccess and permanent redirection issues - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about seo, htaccess, wordpress, 301-redirect, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I have a WordPress website hosted on Bluehost which contains the following URL pattern: http: //www.example.com/2017/01/30/sample-post/ I want to permanent redirect it to use this: http: //www.example.com/sample-post/ So I opened .htaccess kept in the example.com folder and changed it to this RewriteEngine On RedirectMatch 301 ^ /([^/ ]+)/$ http: //...

What does ^(.*) mean in a rewrite rule, is there a simpler alternative?

What does ^(.*) mean in a rewrite rule, is there a simpler alternative? - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, 301-redirect, mod-rewrite, , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I have just copy and pasted a rewrite rule for a redirect from some website. It contains: ^(.*) I want to know what it means. Why is it so complicated? Can it be simplified? The whole .htaccess file currently contains: # turn on the rewrite engine RewriteEngine On # unconditional redirect to the new web RewriteRule ^(.*) h...

How to redirect all pages of site A, including those with query strings, to homepage of site B

How to redirect all pages of site A, including those with query strings, to homepage of site B - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, redirects, 301-redirect, mod-rewrite, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I want to redirect all pages of SiteA to homepage of SiteB . I used this code in SiteA's .htaccess file: <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^(.*)$ https://SiteB.tld/ [R=301,L] </IfModule> The code works perfectly, but not for URLs with Question Mark...

How to Remove Extensions From, and Force the Trailing Slash at the End of URLs?

How to Remove Extensions From, and Force the Trailing Slash at the End of URLs? - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about mod-rewrite, htaccess, url-rewriting, , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : Example of current file structure: example.com/foo.php example.com/bar.html example.com/directory/ example.com/directory/foo.php example.com/directory/bar.html example.com/cgi-bin/directory/foo.cgi* I would like to remove HTML, PHP, and CGI extensions from, and then force the trailing slash at the end of URLs....

Apache doesn't redirect subfolders

Apache doesn't redirect subfolders - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, wordpress, apache, mod-rewrite, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I'm having trouble configuring my Apache server through the .htaccess file. I want to redirect all request from my domain ( example.com , www.example.com , example.com/folder1/folder2 ) to my new domain ( new-example.com , www.new-example.com , new-example.com/folder1/folder2 ). My .htaccess looks like: # BEGIN WordPress # Las directivas (líneas) e...

htaccess , htpasswd and error 401

Image
htaccess , htpasswd and error 401 - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, authentication, htpasswd, , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I have a problem with htpasswd. I get an error in error.log apache2 user admin: authentication failure for "/": Password Mismatch Content of my htaccess file: # Set Access Restrictions AuthType Basic AuthName "admin" AuthUserFile ".htpasswd" require valid-user and content of my htpasswd admin:xxxxx Solution : From your comment ...

How can I use .htaccess to rewrite different domains to different sub-directories, masking the sub-directory?

How can I use .htaccess to rewrite different domains to different sub-directories, masking the sub-directory? - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, redirects, directory, url-rewriting, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I have a shared hosting plan that allows unlimited addon domains, but they can only point to the public root (/). I use .htaccess to point different domains to their corresponding sub-directories. For example, site1.com points to sub-directory /site1/ site2.com points to sub-dir...

How can I create a shorter alias URL to a longer URL using an .htaccess file?

How can I create a shorter alias URL to a longer URL using an .htaccess file? - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, url-rewriting, , , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : Using an .htaccess file, I want to make one specific URL have a shorter alias like this: Original URL: mydomain.com/index.php?option=com_obrss&task=feed&id=2:rss1klik&format=feed&Itemid=160 Alias to the original URL: mydomain.com/index.php/rss/rss1klik Note that both URLs should display the same content. Sol...

Best way to move site from subdomain to root through cPanel?

Best way to move site from subdomain to root through cPanel? - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, redirects, subdomain, , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I have an old Wordpress blog hosted on a subdomain (sub.mysite.com) with hundreds of posts. The root domain is actually empty and redirected to the subdomain. Now I want to move the site from the subdomain to the root domain. I found some .htaccess examples like this: RewriteEngine on RewriteCond %HTTP_HOST ^sub.example.com$ RewriteRule ^(....

Can I set Cache-Control in the .htaccess file for a specific part of a document (just a section of the <body>)

Can I set Cache-Control in the .htaccess file for a specific part of a document (just a section of the ) - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, performance, http-headers, cache-control, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I noticed, by using Google Page Speed Insights , that if I structure my HTML to load the critical, above-the-fold content first, my page will improve performance - and it woks (with now current perf. of Mobile 71/100 - Pc 87/100). My question is, with Apaches's mod_header act...

Redirecting URLs when launching a new website - how to avoid dropping page rank

Redirecting URLs when launching a new website - how to avoid dropping page rank - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about seo, search-engines, htaccess, url-rewriting, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : i have over 100 urls in my website which i need to redirect: E.g. /page/how-to-bake-chocolate-cookies/ will redirect to /cookies/how-to-bake-chocolate-cookies/ /page/contact/ will redirect to /contact-us/ and so on... I want to make sure search engines will catch the new url without affecting my site's q...

htaccess block access to directory but allow access to files

htaccess block access to directory but allow access to files - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, looking-for-a-script, 403-forbidden, , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I need to block directory access but allow access to files if typed into a browser. Also would like this to load my custom 403.shtml Solution : Options -Indexes ErrorDocument 403 /path/to/403.shtml Both lines go into an .htaccess file in your root directory Additionally, if you would like to do some further testing, g...

How to redirect lowercase to uppercase

How to redirect lowercase to uppercase - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, redirects, wordpress, 301-redirect, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I have a WordPress blog and I made subfolder like this https: //example.com/Tourism but when I open this URL with lowercase "t" it shows me 404 not found error: https: //example.com/tourism this subfolder has a lot of posts and when I open "tourism" (with lowercase "t") it shows me 404 not found. How can I redirect all ...

Rewritting .htaccess file to direct to files using a wildcard

Rewritting .htaccess file to direct to files using a wildcard - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, , , , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : Currently my html code points to www.example.com/images/sub/ABCimage.jpg www.example.com/images/sub/XYZimage.jpg Due to a limit on number of files (9999) within the folder , I had to split images into different folders, and it looks like this: /images/sub/ABC ABCimage.jpg ABCimage2.jpg ABCimage3.jpg /images/sub/XYZ XYZimage.jpg XYZi...

Htaccess 301 redirect dynamic URL

Htaccess 301 redirect dynamic URL - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, 301-redirect, , , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I don't know a whole lot about .htaccess rules so forgive and help me ask the correct question. Currently I have a .htaccess rule like: RewriteRule ^surveys/(S+)/directory/(d+)/(d+)/entry/(d+)/?$ directories/index.cfm?sFuseAction=XXX.YYYY.ZZZZ&nDirectoryID=$2&nEntryID=$4&nCategoryID=$3&sDirectory=$1 [NC,L] which I want to do a 301 redirect to: Rewrite...

Add content to start of all requests

Add content to start of all requests - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, html, configuration, , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : In a .htaccess file or another server configuration file, is there a way to add content to the start of all requests, for example: index.html World! .htaccess or another server configuration file # Fake code addContent("Hello"); And then when you visit index.html you will read Hello World Solution : In .htaccess you can add this # Prepend the file ...

Issue with 301 redirect to Index page only

Issue with 301 redirect to Index page only - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, html, url, php, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I have a bunch of 301 redirects in my .htaccess for old pages, which work great. But a problem that's been plaguing me for years is that there's a lot of links out there to my old index page ( index.html ). I want to redirect them to the new index.php , so as to save link juice etc. (if that's still how it works?) The problem is, if I make a redirect f...

302 redirect but leave the url intact

302 redirect but leave the url intact - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about redirects, htaccess, , , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : Am I able to issue a 302 redirect but leave the URL intact? I want to track accesses to a URL in Google Analytics but just display my home page. I am doing this on the assumption that Google Analytics tracks the URL in the address bar - is this correct? i.e. www.example.com/landingpage google sees URL of www.example.com/landingpage user sees content from www.example.com ...

To Fix HTTP 400-499 error codes with 301 redirects in .htaccess file

To Fix HTTP 400-499 error codes with 301 redirects in .htaccess file - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, wordpress, mod-rewrite, url-rewriting, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : This issue is on WordPress site. I am aware we can change the URL naming convention in WP but I have changed my URL format from date format to simple postname followed by slug as shown below. Old style: www.example.com/2013/02/09/rin​gdroid New style: www.example.com/rin​gdroid Google previously indexed my websites pa...

redirect 204 with htaccess if url contain certain string

redirect 204 with htaccess if url contain certain string - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, apache, mod-rewrite, , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I get tons of url with "undefined" added at the end of url, consisting about 20% of my pageview. I tried to check the troubling script source and can't find it. Tried some solutions but none of them are working. Lastly now i'm trying to send url with "undefined" string to redirect 204 using htaccess is this correct? R...