Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
3
votes
1answer
25 views

Is there a way to set up a redirect in htaccess to convert a folder/paths to a params

After trawling through posts I have this RewriteCond %{HTTP_HOST} ^example.software$ RewriteRule ^downloads$ https://example.software\?mode\=downloads&%{QUERY_STRING} [R=302,L] This works fine ...
1
vote
0answers
25 views

Allowing POST requests to bypass Basic Auth if on given pages

Current Implementation: SetEnvIfNoCase Host ^example\.com$ passreq AuthType Basic AuthName "Restricted Area" AuthUserFile /html/.htpasswd Order Deny,Allow Deny from all Satisfy any Require ...
2
votes
0answers
30 views

Issue using htaccess to redirect to main domain's subdir for everything except specific subdomains (and subdirs)

Currently we have an htaccess setup using the below settings; RewriteCond %{HTTP_HOST} !^(staged|foobar)\.example\.com$ [NC] RewriteCond %{REQUEST_URI} !/(Press_Kits|logos|admin|console|shop)/ [NC] ...
2
votes
0answers
29 views

Anything here that can be blocking my site from being indexed by Google / Bing? [closed]

I'm unable to get my site indexed by Google or Bing. Robots and sitemap have been submitted but no love... I think the issue may be in the .htaccess file. Is there anything in here that may be causing ...
1
vote
0answers
56 views

301 redirect a subdomain and all its variants (https, www, etc) [closed]

I want to redirect 301 from abc.example.com to example.com/abc.html page. I would like to include all variants of the subdomain in the redirect, like abc.example.com www.abc.example.com https://www....
3
votes
2answers
379 views

How to Leverage Browser Caching for Fonts in WordPress

I am using WordPress along with Autoptimize and Cloudflare, and using Locally hosted fonts. I can't leverage browser caching on my site. I tried using Cloudflare Page rules to Leverage 1 year browser ...
2
votes
1answer
32 views

Use RedirectMatch in htaccess for many URLs

I need to redirect: https://example.com/thispath/beach?start=20 https://example.com/thispath/beach?start=40 https://example.com/thispath/beach?start=60 etc... to: https://example.com/thispath/beach ...
2
votes
1answer
50 views

Hide site from google search if visitors country is not Ukraine

I want to hide site from another countries but not Ukraine. It has to be hidden in google search. I heard that it could be done with Cloudflare but I don't know how to do this.
3
votes
1answer
162 views

How to redirect a URL and remove parameters using .htaccess?

I'm trying to redirect a URL ending with parameters to another URL without those parameters. https://example.com/newsroom/news-events/news.html?L=1&tx_news_pi1%5Bnews%5D=29&tx_news_pi1%...
2
votes
1answer
26 views

htaccess - RewriteCond is met, but RewriteRule doesn't run

I am trying to match both a filename and querystring in my .htaccess file. When using an online testing tool (this one), it tells me that the conditions are being met, but the following rule doesn't ...
2
votes
1answer
54 views

Content that should be protected is served without authentication intermittently

Our website hosting is with a shared hosting provider. The only configuration we can make is through .htaccess files, we can't touch the apache configuration files that are sourced when apache first ...
2
votes
1answer
50 views

Block access to multiple files with .htaccess - RewriteRule and FilesMatch fail

I am trying to block access to specific files. Neither the RewriteRule or FilesMatch rules I have tried work on the live server, it serves the files as normal with status 200 OK (I'm expecting 404 ...
3
votes
1answer
75 views

sitemap.xml and serviceworker.js are location-sensitive files. But sensitive to the location in the request path or to the actual filesystem location?

I really like the idea of using .htaccess rewrite rules in combination with the /.well-known/ folder for keeping my webspace tidy and coherently / consistently organised. For instance, I know that ...
1
vote
1answer
41 views

multilingual hreflang & .htaccess

I have found several questions concerning multilingual websites and .htaccess rewrite rules. Unfortunately I am only dealing with my website once a year and I am unable to interpret those answers to ...
1
vote
1answer
35 views

Https- and www-redirects accepted by Google Pagespeed Insights

This question builds on this stackexchange-thread The question of mentioned thread was how to write a proper http-to-https and nonwww-to-www redirect, that Google Pagespeed Insights would approve of. ...
1
vote
1answer
30 views

Wordpress multisite non-www URL redirects to mainsite. www version of url is okay and comes to subsite homepage. Why?

So I just made a subsite today and everything was okay until I noticed: If I type the URL of the subsite without the www part, it redirects to the main site. Does anyone know why is that? Before I ...
1
vote
1answer
35 views

How can I redirect a new bare domain to its subdomain without hurting SEO? [closed]

I want to install my new site content on a subdomain like subdir.example.com instead of the root domain. This is a new domain and it has no previous content to redirect. The root URL will be empty and ...
1
vote
1answer
93 views

A modern global rewrite command for HTTPS websites without cname (www.) at all

I host a MediaWiki website on a shared server with Apache, MySQL and PHP. Up until today I used a CDN to deliver that website's content --- which required redirecting each webpage to a www. including ...
2
votes
1answer
36 views

301 Redirect from URL with query string to new URL without query string

I'm having trouble working out how to do a 301 redirect from: https://www.example.com/catalogue/catalogue.php?catSection=1 to https://www.example.com/hire-category/access-support-equipment/ I've tried ...
1
vote
1answer
432 views

How to replace '?' and `=` with slashes in a URL using .htaccess?

How to replace ? and = with / in the URL? I think it may be in .htaccess. Example: example.com/public/Micheal-Smith would look like example.com?public=Micheal-Smith if I didn't replace the ? and = ...
1
vote
1answer
22 views

Htaccess redirect rule adds an unwanted variable

I'm trying to redirect logged-in users that land on a page to another page, but the redirect keeps adding the logged-in user's name to the path / URL. Say I'm logged in as Mario. The redirect ...
0
votes
0answers
48 views

.htaccess script working in Chrome/Safari but not in Firefox

Purpose of the script is to allow traffic only if referred to from a link / php script on the website itself. Direct access to link should not be allowed. Referral from 3rd party website should also ...
1
vote
1answer
35 views

Safe way to block unwanted bots without potential impact on good ones

Currently, I have blocked several bots in htaccess (apache 2.4) like this. (Have used imaginary bot names in the below example.) SetEnvIfNoCase User-Agent .*abcbot.* bad_bot SetEnvIfNoCase User-Agent ....
1
vote
1answer
42 views

Can I use the .htaccess file or another solution to address www and non-www duplicate content issues?

Ahrefs is returning a series of duplicate content URLs for my own website i've asked them about and which they've said needs to be addressed on the CMS side, and which they cannot help with. The ...
1
vote
1answer
26 views

htaccess: request file by partial name

With the assistance of htaccess, is it possible to have files stored as... /content/001 Some sort of description.html /content/002 Some sort of description.html ...or as... /content/Some sort of ...
2
votes
0answers
32 views

Is “cbsearch.site” a web robot, and if yes, how do I block it?

I saw invalid traffic in my Google AdSense account. I read some articles from the web, which all made it clear that invalid traffic could be caused by web "robots". So I tried to read on how ...
1
vote
1answer
60 views

.htaccess directives fail to redirect www to non-www URLs

I'm trying to redirect https://www.example.com to https://example.com. I'm running Ubuntu server 2020 lts with Apache 2, PHP 7 and Let's Encrypt SSL. My file structure: logs/ private/ public/ └ ...
3
votes
1answer
81 views

Force HTTP to HTTPS except one page accessed via HTTP

I'm trying to redirect a website to HTTPS, but there is one URL that needs to be accessed via HTTP. Currently I just have this in .htaccess: Redirect 301 / https://www.example.com I need to have the ...
3
votes
1answer
57 views

IIS rewrite rules for SEO friendly URLs don't work in .htaccess for Apache

I'm using a Pi 3 for the Apache server but I can't figure out how to setup .htaccess. Previously I used IIS with which it is easy to implement SEO-friendly URLs. Linux .htaccess is very different and ...
3
votes
1answer
79 views

Combine multiple 301 redirects

I need to combine multiple redirects via my .htaccess in Wordpress for future site migration and re-launch: Domain change Force HTTPS Force www URL structure changes (important to keep juice here) I'...
3
votes
1answer
138 views

Cookies for www and non-www different

I just discovered that cookies for www and non-www are different. I now understand that the browser treats example.com and www.example.com as two different domains. In detail, how can I assure that ...
8
votes
2answers
2k views

I bought a domain to do a 301 Redirect - do I need to host that domain?

I'm competent with setting up records for domains, things like CNAME, A Records, etc - but what about if I just want to redirect it? Do I "have to" do this using a .htaccess file on a host? ...
2
votes
0answers
55 views

Prevent search engines from crawling and indexing all domains and subdomains set up under an Apache server

My company is renting a CentOS server, with one main domain and ~30 subdomains (the number varies, but it's usually around 30) hosted on it. The subdomains themselves are used for various purposes (...
2
votes
1answer
895 views

Redirect from index.html to its directory using .htaccess?

For each page of my website, it is named index.html and stored inside a folder of the name of the page. example.com/ serves example.com/index.html example.com/about/ serves example.com/about/index....
1
vote
1answer
23 views

Subdomain rewrites without using certs that don't support sub domain affecting

I am using LetsEncrypt to generate and renew my certs for my website. Unfortunately, it does not support subdomains. Having said that, I have a ton of rewrite rules that work fine. For example: ...
1
vote
1answer
59 views

Htaccess - replacing a query string with a numeric value

I don't know why but this htaccess item doesn't work for me. I have something like this after update user profile public/user_profile/show_user.html?id=4 and I want to have public/user_profile/...
2
votes
1answer
151 views

How can I rewrite all Files to the Index Folder and also Remove the Extensions

I've been looking for a solution for a few hours now, and I'm struggling to understand why the Regex doesn't act like Regex... If you just try to match a letter, it doesn't match a letter, and I can't ...
2
votes
1answer
49 views

Apache doesn't redirect subfolders

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 (...
1
vote
1answer
194 views

PHP Undefined index: REDIRECT_STATUS - error 404

Custom 404 page in PHP using .htaccess file. If page dosen't exist redirect to error.php. I don't know why but it doesn't work. Notice: Undefined index: REDIRECT_STATUS on line 2 <?php $error = $...
1
vote
1answer
249 views

Htaccess RewriteCond based on environment variable

I find apache very unfriendly. Anyway. I have this: RewriteRule (.*) - [QSA,E=DOMAIN_NAME:localhost.com] This doesn't redirect, which is fine: RewriteCond "www.%{ENV:DOMAIN_NAME}" "!=...
2
votes
2answers
64 views

Point all to index.php conflict with a private directory

Here is my website structure (root): private public .htaccess index.php The htaccess file contains: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ /index.php [L] Having this said,...
1
vote
1answer
28 views

What's the difference between access and access plus in ExpiresByType directive?

I have seen: ExpiresByType image/jpg "access 1 year" But also: ExpiresByType image/jpg "access plus 1 year" So, what's the difference between those two lines ?
1
vote
1answer
20 views

What types of files does ExpiresDefault include?

I have: ExpiresActive On ExpiresByType image/jpg "access 1 years" ExpiresByType image/jpeg "access 1 year" ExpiresByType image/png "access 1 year" ExpiresByType image/gif ...
1
vote
2answers
52 views

How ExpiresByType and Header set Cache-Control works together?

I have: ExpiresActive On ExpiresByType image/jpg "access 2 years" And let's say: <filesMatch ".(jpg|jpeg|png|gif)$"> Header set Cache-Control "max-age=31536000, ...
3
votes
1answer
108 views

Rewrite wildcard rule to redirect images that works with HTTP, HTTPS and Firefox HTTPS-Only mode

This set of rules causes the nolinks.jpg image to appear if anyone tries to link directly to an image from a remote site. It is working well but with the latest Firefox, the browser is forced to ...
2
votes
0answers
23 views

Problem with URL path when I applied SEO friendly URL [duplicate]

I was working on PHP project and making SEO friendly URL Like, OLD : http://example.com/list_product?q=men-top-wear New : http://example.com/list_product/men-top-wear Here is my .htaccess file: ...
1
vote
0answers
23 views

Understanding mod_expires apache module [closed]

Working with htaccess is a new capitol for me. I have already read about mod_expires here https://httpd.apache.org/docs/current/mod/mod_expires.htm, but I'm stil confused. I have the next code from ...
2
votes
0answers
30 views

Is ifModule in htaccess a bad practice? [duplicate]

Can someone give me a good reason why users are using ifmodule in their htaccess ? <IfModule mod_headers.c> Header set Cache-Control "max-age=290304000, public" </IfModule> # ...
1
vote
0answers
59 views

Understanding htaccess cache rules [closed]

Ok. I've read a lot and I understand almost nothing. I talk about cache, and I don't know any cache system that is interested in keeping my files, for me, and for free. And, as I read, there are ...
3
votes
1answer
64 views

What will happen if I have two htaccess/robots.txt files in two directories?

I think there is (or I did something wrong) on my site: I installed a pre-made WordPress theme and normally they are installed as 'quick-install-package' with duplicator. When I installed the package, ...

1
2 3 4 5
32