Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
1
vote
1answer
1k 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
40 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
723 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
43 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
41 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
1k 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
6k 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
2k 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
1k 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
421 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
1k 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
903 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
1k 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
50 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
51 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
947 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
40 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
647 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
586 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
1k 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
1k 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
3k 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/ ...
4
votes
1answer
6k 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
131 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
286 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
610 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
141 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
241 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
84 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
442 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 -> ...
1
vote
1answer
51 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
185 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
504 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
139 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
1k 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_-]*...
2
votes
1answer
848 views

Return 410 Gone status for all .html files except a single one?

I bet there's at least one trivial solution to this problem, but I've yet to figure any of them out. In a nutshell, what I'm trying to achieve is, informing the search engines that there are no more ....
4
votes
1answer
866 views

How to add force https to htaccess file RewriteRule with _route_=$1

I inherited support for an Opencart 1.5 site which needs to have SSL enabled. I've edited the config.php files in / and admin/ and adding https:// to the URL is working in the browser and links are ...
2
votes
1answer
44 views

htaccess redirect to another website while cutting a string from address

I'm trying to make a redirect with htaccess. Let's say that I have two websites: www.oldsite.example www.newsite.example What I want to do is redirect old to new with random_file.html renamed to /...
1
vote
2answers
876 views

Forcing trailing slash at end of “fake” folders

The working codes that I've found here most put a slash in everything. I just need force trailing slash in these "fake dirs" (that are part of my rewriting scheme (only directories)) and keep ...
3
votes
1answer
107 views

Redirecting to subdomain, impact on SEO?

I've been working on a web platform project for a client, and we are nearing completion. Basically, the platform is a small social network for a specific group of people. Part of the specification is ...
1
vote
1answer
239 views

How does Google crawl dynamic URLs?

I'm trying to crawl my website using the google webmaster tools, but I'm curious as to if I've setup my parameters correctly. On my website I have different pages that's content is relative to a url ...
2
votes
1answer
1k views

Deny access to one of two sites using the same .htaccess

I need to set up my .htaccess file to deny access to the site if they are accessing the staging.example.com. I have a Magento 2 store and have set up deployment using Capistrano, which will be ...
4
votes
1answer
99 views

How to redirect from https://hi@example.com/x, to just https://example.com/x (htaccess)?

I have a weird problem where for some reason search engines see that I have duplicate URLs, like https://hi@example.com/x and https://example.com/x I'd like the first (i.e. with hi@) to 301 redirect ...
1
vote
2answers
4k views

Forcing https causes all folders to redirect

I have quite a large site that consists of some regular web pages in the root and a lot of Joomla sites in folders. So it looks a little like this: - index.php (root) - about.php (root) - product....
3
votes
1answer
52 views

Redirect IPSuite “?/topic/” URLs to “?thread/” for Woltlab

I moved from IPSuite forums system to Woltlab burning board forum system. What happen next was that my old links that start with: example.com/index.php?/topic/ Now start with: example.com/forum/...
1
vote
0answers
526 views

How to use htacess to Stop Spam hits originating from specific domains? [closed]

I am getting loads of spam/junk hits on my sites, they result in thousands of hits per day which is crippling my server resulting very poor performance on adsense revenue. Although I am blocking them ...
6
votes
1answer
1k views

Rewrite wildcard subdomains in .htaccess to corresponding folders on the main domain while preserving the subdomain

I'm trying to rewrite a subdomain to a folder/file like this: name.example.com -> example.com/profile/name foo.example.com -> example.com/profile/foo xyzzy.example.com -> example.com/profile/xyzzy ...
2
votes
1answer
2k views

How can I make a specific series of URLS have “410” Gone status?

Server was hacked and my .htaccess file was changed to wildcard redirect (spam). I am seeing a lot of requests like those below even after I've cleaned up my server: example.com/cobwebbing-...
1
vote
3answers
2k views

how to properly cache a static website .htaccess

The problem i noticed with my static website. Is that the css is not renewing itself once I updated the website code at areas (Adding new pictues, text, colours). I checked immediately once i updated....

1
4 5
6
7 8
30