Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
-1
votes
0answers
19 views

Redirecting a website from older domain to a new domain URL to URL Mapping [closed]

I have a website example.com I want to move site.example/ site.example/post-1 site.example/post-2 site.example/post-3 site.example/post-4 to newsite.example newsite.example/post-1 newsite.example/...
2
votes
1answer
51 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
36 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
65 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
35 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
31 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
28 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
30 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
89 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
32 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
139 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
21 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
22 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
33 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
39 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
23 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
30 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
58 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
72 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
49 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
60 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
74 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
45 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
585 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
22 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
57 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
88 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
34 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
138 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
136 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
60 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
24 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
17 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
41 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
103 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
22 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
29 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
56 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
60 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, ...
4
votes
1answer
68 views

Rewriting a folder name using .htaccess doesn't want to work

I am wondering, why folder renaming doesn't work. RewriteRule ^pl/(.*) public/$1 Let's say I have a URL like: example.com/public/index.html Now I want to rewrite the URL to example.com/pl/index.html ...
2
votes
2answers
52 views

Excluding homepage from Rewrite rules in htaccess

I would like to have this new prerendering service I'm using NOT apply its magic to the homepage and basically only to pages that begin with https://thechartcast.com/episodes/. Below is the relevant ...
1
vote
1answer
403 views

How to prevent a specific PDF file from being indexed by search engines in Wordpress?

In a wordpress multisite installation, I would like to block indexing of a specific pdf file using HTTP X-Robots-Tag response header using htaccess file. Any of the indications found in previous ...
0
votes
0answers
51 views

How To Fix 404 Errors On An Entire Site?

I have a PPC l client who recently re-designed their e-commerce site. The only problem is that every single old link that they had before is now a 404 error. They had a fairly healthy organic ranking ...
2
votes
1answer
31 views

htacces rules for mobile and desktop site

I have a site that stores an index.php for desktop computers and a mobile.php for mobile devices. Both files are in the same directory (say /var/www). As default the user accesses index.php and if ...
2
votes
1answer
246 views

.htaccess — Trailing slash and characters after file extension

I've got some weird usability warnings popping up in my search console for pages which don't actually exist on my site. It looks like someone is creating 100's of malformed links to my pages. Here's ...
1
vote
1answer
51 views

Clean URL's within subdirectories

I have a website with the following structure index.php contact.php about.html forum(dir) - index.php - thread.php What i want my htaccess to do Remove .php & .html extension, eg: when you ...
1
vote
0answers
43 views

How to fix duplicate title tags canonical for / vs index.html

I am confused, after scanning by an online SEO tool, it says: error duplicate title tags canonical; https://cleanmypc.co.uk and https://cleanmypc.co.uk/index.html I have in my .htaccess file ...
1
vote
1answer
343 views

Htaccess won't work with ajax/php

Sending ajax request by jquery doesn't working with htaccess. Works without htaccess. product_configurator.php -> fetch_data_p.php $.ajax({ url:"fetch_data_p.php", ...

1
2 3 4 5
32