Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
2
votes
1answer
30 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 ...
0
votes
0answers
33 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
16 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
36 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
20 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
28 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
57 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
56 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
43 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
44 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
40 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
39 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
282 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
53 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
51 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
32 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
76 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
74 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
58 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
20 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
16 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
38 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
100 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
53 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
54 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
67 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
47 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
270 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
49 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
29 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
155 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
48 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
39 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
243 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
vote
1answer
24 views

Htaccess Using RewriteMap with a text file

I can't use link with * Example - http://localhost/photo_gallery/public/show_c.html/color-1* The requested URL was not found on this server. The others work's color-3, wood, etc. generated map - map....
1
vote
1answer
42 views

.htaccess url rewrite remove 2 id

Is it possible to delete 2 parameters ID of the url & just show the number. Currently i have url like this: http://localhost/photo_gallery/public/product_configurator.html?prometheus_id=10082&...
2
votes
1answer
35 views

How can I redirect my URL to rearrange the order of subdirectories in .htaccess?

My current URL is example.com/example/{dynamic_id}/{dynamic_name}/static/1.html I want to redirect it to this, example.com/{dynamic_name}/example/{dynamic_id}/static/1.html I tried but failed.
1
vote
1answer
81 views

Url changing with htaccess

I have a web presentation with some typical url adresses. Now I need to add a rewriterule for a different languages, examples: domain/club -> do not change domain/club/path -> do not change ...
2
votes
1answer
90 views

Will deleting and re-upload my new site site help Google index it and resolve duplicate URLs that are now fixed?

I uploaded a new site with a domain name https://example.com (actually the domain consists of 3 words concatenated together). If i do a google search for those three words in Google, the site does ...
1
vote
1answer
69 views

Blocking bad bots based on useragent in apache conf

I am proposing blocking bad bots using the following code in /etc/sites-enabled/site.conf and I have a few questions. RewriteEngine On RewriteCond %{HTTP_USER_AGENT} useragent1|useragent2|useragent3 [...
4
votes
1answer
71 views

htaccess force https not working if there is not an URI

I've never worked with Apache, so I'm a completely newbie. I have a multihosting account on a provider website, where 3 domain are used. I want to force https connection on a domain, let's say example....
2
votes
1answer
181 views

How to Redirect URL with special Characters?

I try to redirect a special URL in .htaccess, as below: Redirect 301 /aor/%e2%80%9d https://www.example.com/outlook-repair/ But this seems does not work. I try to add quotes, as follows: Redirect 301 ...
2
votes
2answers
221 views

Block directory access with .htaccess rules does not work

I am trying to block access to a specific folder and all of its content. I use methods suggested on the Internet, but they do not work. This method does nothing: RewriteRule ^folder_name/?$ - [F,L] ...

1
2 3 4 5
31