Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

3
votes
2answers
191 views

How to use X-Robots-Tag to noindex all subdomains (save specific exceptions)?

Google's Robots meta tag and X-Robots-Tag HTTP header specifications page (Practical implementation of X-Robots-Tag with Apache section) gives an example of noindexing certain filetypes, ie: <...
4
votes
1answer
46 views

Whats the correct htaccess line to direct from sub-domain to main domain

We have a blog on a subdomain which needs to be moved to the main domain ie: blog.example.com/post-title to example.com/blog/post-title Do I need to create a redirect match for each individual post/...
0
votes
1answer
149 views

.htaccess Redirect if no sub string found in the URL

Whenever user comes in example.com how to redirect them to example.com/home Note: The current routing/URL paths should work after adding this condition/rule For example: example.com/about-us -> no ...
0
votes
1answer
31 views

.htaccess rewrite rules working on Mac Apache 2.2 but not on CentOS Apache 2.4

I've run into an issue when moving from a test server to a production server. I have a set of .htaccess rules in a file in the public_html site root: #Root directory htaccess RewriteEngine On # ...
0
votes
1answer
29 views

what is url robot search engine when enter to my website [closed]

what is url search engine robots when enter to my website for example i add this code in .htaccess this code just allow google robots read the robots.txt i need to add url ( msn , yahoo , bing ) ...
1
vote
1answer
80 views

Overwriting cookies in htaccess

I run a website in a quite cheap shared hosting environment (LAMP): technically speaking, in this context the only thing I can do is edit one or more htaccess files. Maybe for load balancing purposes,...
2
votes
1answer
115 views

How to have .htaccess display 404.html for child pages

I am working on a website example.com that has an error page example.com/404.html. Here's my entire .htaccess file (Apache): # Forces HTTPS RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(....
-1
votes
1answer
41 views

I cannot do https redirection on my website on .htaccess

Am having a local classified website. I bought SSL for the domain but cannot put https redirect on htaccess since my developer wrote somerule on htaccess to get url for SEO. Can some help for the same....
3
votes
2answers
247 views

.htaccess using HTTP_HOST has one extra extraneous redirect when forcing HTTPS

When I use these lines in my .htaccess file, everything works well: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ https://example.com%{REQUEST_URI} [L,R=301] Then I tried to make it ...
2
votes
1answer
611 views

Redirect URL without lang directory to default language

This: example.com/test/ should redirect to: example.com/en/test/, but: example.com/es/test/ shoudn't redirect. in this case /test/ could be anything, with any number of levels (i.e.: /test/succeeded/ ...
1
vote
1answer
287 views

.htaccess redirect dynamic URL (with numeric ID) to remove “track” from the end

It seems to be easy, but I can't figure out how to solve it, nothing worked for me. I have a dynamic URL like: http://www.example.com/user/46/track and I want to redirect from that URL to http://www....
1
vote
0answers
20 views

Disallow URLs made with mod_rewrite in robots.txts [closed]

Here is my robots.txt file: User-agent: * Disallow: /head.php Disallow: /head/ Disallow: /head Disallow: /header.php Disallow: /header/ Disallow: /header Disallow: /footer.php Disallow: /footer/ ...
1
vote
2answers
126 views

WordPress multisite ERR_TOO_MANY_REDIRECTS where the domain name ends up in the path for nonexistent pages

I have a WordPress multisite setup with subdomains. I have pointed five subdomains to it. I have also installed SSL to main domain and the other subdomains. I have written the below Redirect code for ...
1
vote
1answer
267 views

RewriteCond %{HTTPS} !=on is not working even though RewriteCond %{SERVER_PORT} !^443$ works

I have a requirement to check for non HTTPS URLs in htaccess. My understanding is that RewriteCond %{HTTPS} !=on will match all URLs that are not HTTPS. But upon testing, I find RewriteCond %{HTTPS} !...
3
votes
1answer
38 views

Problem with .htaccess for files having similar kind of names

I have a file with name lang.php and another file in the same folder with same lang_inst.php. The .htaccess am using is: RewriteEngine On Options -Indexes RewriteCond %{REQUEST_FILENAME} !-d ...
1
vote
0answers
282 views

Cannot figure out how my nodejs application run with apache

I need to push my node app updates to remote host which is really wired. It uses standard cPanel + apache bundle, but also has node installed. Root domain mywired.host hosts static files from ...
2
votes
1answer
40 views

Are these 3 redirect rules equal?

I would like to redirect the non-https and non-www versions my domain to the https and www version of it. I'm a bit confused by the options. Are these redirect rules equal for my purpose? # REDIRECT ...
1
vote
0answers
28 views

.httaccess password protection not working on recently updated browsers

My situation is this: I have a web folder on an Apache server protected with standard .httaccess password protection. It's been working fine for years and the code hasn't been modified in any way. In ...
2
votes
2answers
450 views

How is it best to redirect http to https in cPanel?

I am setting up a new site on a domain that has an SSL certificate. The DNS is all configured correctly and I can access the site on either http://example.com or https://example.com URLs. Currently, ...
4
votes
2answers
819 views

How to force ssl and www for a subdomain as an independent domain?

I have own the example.tld . I want to force SSL and https for root-domain and all of its subdomains. I have used below code in .htaccess file of root-domain: RewriteEngine On RewriteCond %{HTTPS} ...
3
votes
1answer
694 views

How to Redirect Pages with Query String?

I want to Redirect as seen below: https://example.com/p1/p2?sort=p.model&order=ASC&page=2 to https://example.com/p3/p4?sort=p.model&order=ASC&page=2 Also, I have this code in my ....
4
votes
2answers
442 views

Rewrite all URLs within subdirectory to index.html so JavaScript can use the path

I have a part of domain example.com/~mypart. In that folder is index.html. If I visit example.com/~mypart/something I get a "Not Found" error. I want every address with some string after example.com/...
0
votes
1answer
234 views

Remove two subfolders and change plusses to dashes in the URL using .htaccess

I'm in the process of migrating a website from an old CMS to Wordpress. The way that some of the old URLs were: http://www.example.com/tags/tagged/tag/tag+name For Wordpress, I need it to be the ...
6
votes
3answers
771 views

Is an .htaccess edit necessary when enabling Cloudflare SSL?

I have recently changed 3-4 of my sites to Cloudflare SSL. After that, I went to General Settings on WordPress and changed URLs from HTTP to HTTPS. And it redirects from HTTP to HTTPS without any ...
1
vote
0answers
410 views

How do I serve webp images from my WordPress site but exclude the WP backend/admin

For some reason that I cannot fathom, my Chrome installation does not show me webp images from my website. I can see webp images on other sites (I think - how can you tell if you are being served a ...
4
votes
1answer
314 views

Can a URL with a # anchor be redirected in .htaccess?

I believe this can't be done, but it would be good to confirm either way. To know if it's worth investing more time in or not. Can a .htaccess file rewrite/redirect: example.net/postname#heading2 ...
1
vote
0answers
42 views

How best to handle a common mis-spelling of my domain name?

My surname is Kirkby, but very often people mis-spell it, by leaving out the second 'k' and so spell it as Kirby. My domain name is kirkbymicrowave.co.uk, but I took a guess that a few people at ...
2
votes
1answer
39 views

Redirecting from one page to another page on my website causes 404 error after using .htaccess file

Currently I'm working on a PHP blog. Where I have used an .htaccess file to get a clean URL, here is the code: RewriteEngine On RewriteCond %{HTTPS} !=off RewriteCond %{HTTP_HOST} ^example\.com$ ...
2
votes
1answer
378 views

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

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/ [...
1
vote
0answers
33 views

.htaccess redirect to new domain with new page name [closed]

Does anyone know how (or if) I can do an .htaccess redirect if both the domain and page name have changed? I can get olddomain.com/page/ to redirect to newdomain.com/page/ (same page name), but not ...
3
votes
1answer
197 views

Are there any tools in Google Search Console for removing URLs with 301 redirects?

In Google Search Console, I am getting 15-20 all different URLs in 404 section which is not in proper format(this URL is too old around 6-7 years and there is no 'Linked from' for this URLs). I want ...
0
votes
1answer
46 views

Deprecating old URLs using htaccess

Currently I have this in my htaccess file: RewriteEngine on RewriteRule ^chart-(.*)\.php$ ./keyboard-chart.php?seo=$1 [QSA] RewriteRule ^keyboard-diagram-(.*)\.php$ ./keyboard-chart.php?...
2
votes
2answers
290 views

Robots.txt to disallow on multi level subdomains

I've got a server, where I have multiple development projects for clients. While developing, each instance lives on client.dev.example.com. I need to stop crawlers from crawling the development ...
1
vote
1answer
603 views

Force non-www https mode for a dirctory and its sub-folders

My root website (example.com) and its folder (example.com/folder) have two different CMS (Opencart for example.com and WordPress for example.com/folder). I use this code in example.com to force non-...
3
votes
3answers
418 views

Blocking bad bots in .htacess - should I add a BLOCK list or ALLOW list?

I got my Siteground hosting account suspended yesterday due to the allowed CPU overage. Besides recommendation to disable or control the WP heartbeat API, I was also recommended to block bad bots and ...
1
vote
2answers
1k views

How to redirect all pages in /directory/ to webpage with htaccess

I am trying to redirect all pages on my site in one directory to a specific page using htaccess. Example anything like example.com/forums/ example.com/forums/pages example.com/forums/subdirectory/ ...
3
votes
1answer
2k views

What does this htaccess file do in this configuration?

I've never seen this configuration in .htaccess. This comes from my site that currently reset. I have no SSL certificate installed, but I remember seeing these names on previous certs though. So does ...
1
vote
0answers
58 views

Mod_Security false positive, how can I whitelist?

I am getting the following error while I am trying to create a web service. How can I white list this user agent? I am not really able to understand the following error message. [error] [client ...
1
vote
0answers
165 views

.htaccess How to redirect some specific pages, then a blanket rule to new domain?

I am creating a new website on a new domain, and doing page-to-page redirects from the old website for (A) all static pages, as well as (B) all blog posts. A) The static pages follow a new URL ...
2
votes
0answers
250 views

.htaccess for two languages and corresponding redirect for every page based on accept-language

I have a website www.example.es, with this structure: www.example.es index.php 404.html somepage.html www.example.es/en index.php 404.html somepage.html I want to redirect any language but es to ...
3
votes
4answers
114 views

Hold my hand through my htaccess http to https redirects

I've been researching the best way to handle my htaccess file in order to switch from http requests to https and I've seen everything from basing requests off server ports, using server name requests ...
1
vote
1answer
110 views

How to use htaccess file for site migration?

We are doing a site migration. The protocol will change from HTTP to HTTPS. The server IP will differ (but in the same region), as the web agency says we can not have the same domain on two IPs. So ...
0
votes
2answers
78 views

General questions on operation of SSL secured sites [closed]

I am trying to get some understanding on differences between unsecured (http:// accessed) and SSL secured (https://) websites on Apache servers. So I am not trying to solve a specific problem right ...
2
votes
1answer
116 views

.htaccess - how do i redirect TLDs?

I'm currently using my .htaccess to force all HTTP requests to HTTPS, and that is working very well. However I would also like to redirect some TLDs. For example - http(s)://(www.)example.info -> ...
0
votes
0answers
56 views

How can I remove an .html extension and the name of a parameter using .htaccess?

I have tried lots of URL rewrite rules in my .htaccess, but I am stuck now. How can I change this URL: blogs.html?title=Responsive%20web%20design to this URL: blogs/Responsive%20web%20design
1
vote
1answer
45 views

.htaccess Rewrite whole dir contents to another

I am trying to rewrite the whole contents of a directory to the home url. so, if someone visits www.example.com/bnn27sh32j@d299/gold it should take them to www.example.com/gold I have tried: ...
1
vote
3answers
92 views

Help with HTACCESS redirection to HTTPS

I have inherited a web app. It's running fine. But it's using HTTP, not HTTPS. This is the .HTACCESS file: Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ ...
0
votes
1answer
220 views

htaccess force HTTPS except two pages

I would like to force HTTPS (SSL) on every page except /es-ES/calculador-cuatro-pilares-destino-bazi.html or /en-US/bazi-calculator.html. How can I do that? I am using Apache HTTP Server (ver 2.2.x). ...
1
vote
0answers
81 views

Trouble with .htaccess rewriting .png/.php [closed]

I'm currently creating a "dynamic signature" for a forum or email signature. The php code writes perfectly fine onto an image with the .php page. When trying to access the .png file with the ...
1
vote
1answer
637 views

How to keep question mark in URL rewriting with a GET method?

I am trying to use URL rewriting to rewrite search-en.php?q=abc to pages-afficher-recherche.php?lang_abbreviation=en&q=abc and I did RewriteRule ^search-([a-zA-Z]{2})\.php\?q\=([a-zA-Z0-9_-]*...