Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
0
votes
0answers
18 views

How to set up htaccess to redirect all URLS to new domain main page (no path)? [duplicate]

So I have domain http://example.com. I want to setup htaccess to redirect all of these variations http://www.example.com http://example.com https://example.com/111 http://example.com/222 ... ...
2
votes
2answers
94 views

How to set up htaccess to redirect all URLS to new domain?

So I have domain http://example.com. I want to setup htaccess to redirect all of these variations http://www.example.com http://example.com https://example.com/111 http://example.com/222 ... ...
4
votes
1answer
72 views

Link from a Wordpress page to a password protected non-Wordpress page on a subdirectory

I have a Wordpress site which contains a link to a non-WordPress (i.e. pure Html) page sitting on a subdirectory of the same domain. It all works fine at the moment but now I wish to password protect ...
2
votes
1answer
31 views

Google Sites: 301 Redirect broken links to the home page

Several months ago, I migrated my domain from GoDaddy to Google Domains and now use Google Sites. Several broken links from the old GoDaddy webpage highly ranked on Google Search persist. I would ...
2
votes
2answers
26 views

Redirect 404 Sub Directories to the equivalent sub-domain

We're moving thousands of sub directories, to a sub domain. The exact same slug, but its a sub domain now. All of these sub directories are going to cause a 404. Using htaccess, how can I take the ...
1
vote
0answers
22 views

Cloudflare + Forced SSL + auth on directory

I hope I'm asking in the right area. Here's what I have. Apache 2.4.18 on Ubuntu 16.04 server. I have my main website in a vhost, call it domain.com. This is proxied through CloudFlare. I also ...
2
votes
0answers
64 views

How do I redirect thousands of WordPress URLs to a subdirectory?

I have a WordPress website and it has almost 22,000 blog posts. It has been running with good SEO for the past 6 years. The contents are scattered in almost all social media and backlinked in a lot ...
2
votes
1answer
23 views

htaccess rewriterule not working for old urls for site rebuild

I am struggling to get the rewrite rules working in .htaccess for search links on a property rental website I am working on. The old links are like this: example.com/index.php?proptype=Villa&...
2
votes
1answer
46 views

Use .htaccess to remove a directory and .php extension from the URL

I am running a Wordpress website, but I have some folders not related to the wordpress CMS, but in the same directory where all Wordpress folders are. The .htaccess in root WP folder has its standard ...
1
vote
1answer
31 views

How redirect directly to the final domain URL rather than a chain through variations of `www` and `https`?

When I type example.com in the URL it first redirects to http://example.com then to https://example.com and finally to the https://www.example.com (the original address). Why doesn't it straight away ...
2
votes
1answer
39 views

htaccess redirect each CSS URL to another CSS file

I want to redirect every URL which ends with .css to a specific CSS file. This is because we are using Mouseflow for analysis and sometimes we generate a new CSS file. Mouseflow is then trying to ...
4
votes
1answer
250 views

Deny access to all PHP files using FilesMatch, but make an exception for one file

Currently, using htaccess I am denying access to any PHP file in a directory, but not the JS, PNG, CSS files in the same directory. <FilesMatch "\.php$"> Order deny,allow Deny from all </...
2
votes
1answer
30 views

Redirecting index.html to root + folder index.html to root folder? (multilingual)

I have example.com page. I want a homepage without index.html (example.com/index.html -> example.com) RewriteEngine On RewriteRule ^index\.html$ / [R=301,L] RewriteRule ^(.*)/index\.html$ /$1/ [R=301,...
2
votes
1answer
39 views

Redirect hundreds of subdomains to the main domain with path forwarding, use .htaccess?

I want to redirect from a subdomain to domain along with URL path forwarding. Example: abc.example.com/products.html TO another.example/products.html The trailing URL should be preserved. We ...
2
votes
1answer
62 views

.htaccess, redirect all to bye.php, even with more slashes, with exception

I need, in .htaccess, redirect all behind domain, but even with more slashes and with slash or no slash at the end, but with one exception. For example example.com/all/sites/should/redirect/to/one/...
2
votes
1answer
56 views

Block/allow access to certain PHP pages

I have a number of PHP scripts that are meant to be included into other PHP scripts, but otherwise should not be directly accessible to anyone via a Web browser. How do I block people from accessing ...
3
votes
1answer
99 views

PDF files still indexed when X-Robots-Tag noindex set in .htaccess

I am trying to analyse the .htaccess file of a website, specifically the following piece of code: <FilesMatch ".pdf$"> <IfModule mod_headers.c> Header set X-Robots-Tag "noindex, noarchive,...
1
vote
1answer
125 views

htaccess redirect based on referrer URL string

I have a 3rd party who POST's to a specific page on my website. They post a file and my site does some wizardry with the contents of that file. The request URL would be for example https://example....
1
vote
1answer
35 views

subdirectory htaccess url rewrites

I have a project with this skimmed structure: -proj -----pages ---------example -------------pages -------------.htaccess ---------.htaccess I managed to get it working so that all url's go to /...
1
vote
2answers
21 views

Why doesn't my .htaccess file redirect my old WordPress permalink structure?

About 9 months ago i changed my permalink structure in WordPress from the domain.com/year/month/article-name format to the domain.com/article-name one. I hired someone to do the rewrite rules for ...
3
votes
1answer
35 views

WP Apache .htaccess redirect .com traffic to .co.uk Issue

I have a website I am looking to redirect .com traffic to .co.uk. For the moment, when I navigate to https://example.com, it redirects to https://www.example.co.uk and displays as such in the address ...
2
votes
3answers
140 views

Using htaccess to force HTTPS doesn't work

NEW EDIT 28/oct/19 → I edited the .htaccess file as you said AddHandler x-mapp-php5.5 .php # HTTP to HTTPS redirect RewriteCond %{SERVER_PORT} 80 RewriteRule (.*) https://www.bebechan.net/$1 [R=301,...
3
votes
0answers
35 views

Redirected to www, but Google is indexing no-www without snippets, should I use noindex instead?

I started my blog a month ago and was using non www version for my website. Then, I recently decided to stick to www.example.com version. So I changed it and Google has indexed the www version ...
1
vote
1answer
12 views

.htaccess HTTPS fowarding still redirecting to a folder which I have removed from the rule

I have the following simple code in my .htaccess file in order to forward my domain to the HTTPS version of the website: RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://...
0
votes
0answers
139 views

check if Url contains special character like #

I have site setup in wordpress as root folder like /wordpress and one angular site setup in sub folder /wordpress/angular. Currently if user visits url like mydomain.com/wordpress/sample-page, it ...
2
votes
1answer
172 views

Forcing all requests to HTTPS vs not forcing all requests

I'm not new to cleaning up mixed content errors after switching from http to https and I'm not new to working with the htaccess file but I am new to actually implementing the rules for http to https ...
2
votes
1answer
31 views

Redirect all aspx in a subdirectory to new location

How can I redirect: http://example.com/subdir/a.aspx http://example.com/subdir/b.aspx http://example.com/subdir/c.aspx ... to: http://example.com/subdir/ with .htaccess please? Note, I have these ...
4
votes
1answer
53 views

Problem opening files with encoded filenames

I have a website where users can upload files, if they upload a file with a special character in the filename, the filename will be encoded (for example: iordănescu.pdf will become iord%C4%83nescu.pdf)...
2
votes
1answer
29 views

Deny Multiple Spammy Domains via htaccess

<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_REFERER} ^http(s)?://([^.]+\.)*tumblr\.com [NC,OR] RewriteCond %{HTTP_REFERER} ^http(s)?://([^.]+\.)*nometoqueslashelveticas\.com [NC,...
3
votes
1answer
46 views

htaccess conflicts

The issue that I'm currently forced to handle is related to a folder structure URL being redirected to the same folder structure URL but with a different string. So page-a used to exist but that ...
2
votes
1answer
68 views

How to configure .htaccess to rewrite all requests into a folder, except a list of exceptions

I have an established website with some legacy folders I would like to keep. https://example.com/.well-known/ https://example.com/Music/ https://example.com/Rutabagas/ I've also installed ...
4
votes
1answer
37 views

Reorder parts of URL path to put date together using .htaccess redirects

old permalink: https://www.example.com/2019/cat/subcat/10/25/post-name/amp/ new permalink: https://www.example.com/2019/10/25/cat/subcat/post-name/amp/ How can I redirectmatch the old format to ...
1
vote
1answer
36 views

Does it hurt to have multiple .htaccess_backup files?

Today I saw .htaccess_backup files in my file manager. Does it affect SEO or something else? Should I delete all the .htaccess_backup files or does it not matter?
3
votes
2answers
293 views

Block ip range using htaccess

I'm looking for a good way to block an entire IP range using htaccess. The problem I'm having is that the block I need to ban is 100 IP ranges big. From a programmers perspective it should be easily ...
3
votes
1answer
39 views

What is the Cloudflare equivalent of these two .htaccess redirect rules?

I usually set up my sites to rewrite URLs in the following cases: All http traffic is redirected to https (and www), with a 301 All non-www traffic is redirected to www (and https), with a 301 In ....
2
votes
1answer
26 views

.htaccess to redirect subdirectory to its own domain name

I have for example 2 domain names gl.example that points to /public_html/ (which has subfolder /public_html/tlf/) and tlf.example that points to the subfolder /public_html/tlf/ How do I redirect so ...
2
votes
1answer
23 views

wordpress multisite htaccess redirect site to TWO subsites

EDITED: I've split a website into two subsites in a multisite enviroment. The old site was moved to a subsite, and renamed old.mysite.example. This will be faced out at some point. During ...
1
vote
2answers
69 views

www to non-www 301 redirect doesn't work

I am redirecting 301 in cpanel www to non-www (naked domain) and the code Cpanel redirect generates doesn't do anything when www to non-www is set. Server Type: (Litespeed Server, domain has "Let's ...
1
vote
1answer
42 views

Use .htaccess to redirect to add .txt extension

I have a .txt file on my hosting and would like to redirect to it if somebody enters an specific website within their browser, e.g. example.com/webpage --> redirects to --> example.com/...
2
votes
1answer
283 views

Google Could Not Fetch Sitemap

Sitemaps are necessary part of our web work, and we need them to get more "Google love". But for the past one month or so, I have not been able to submit sitemaps on Google search console. I used ...
2
votes
1answer
33 views

How to rewrite using .htacess when there is a ? (question mark) at the beginning of the URL?

Many JS functions on my site are sending Ajax request to /?something=3213214 but I need to redirect them to /something=3213214 When I do: RewriteRule ^test/(.*) /$1 [R] It does redirect /test/...
0
votes
1answer
20 views

Bad route appended to URL when redirecting from http to https

I have a WordPress site hosted on OVH and I'm having issues when redirecting from http to https. http://www.example.com redirects nicely to https://www.example.com https://www.example.com redirects ...
2
votes
3answers
72 views

How can I use the .htaccess file to redirect all web requests to a subfolder with SSL also?

OK, I have a basic php website (non WordPress) that I just moved from GoDaddy to Nixihost. By default, the root website gets put in the root web folder /public_html - however instead I wanted the root ...
2
votes
1answer
27 views

I can't run 2 or more url rewriting rules at once

I was trying to shorten the URL more, but I was removing .php file extension from the URLs using URL rewriting too. I can't run both at the same time. Removing the extensions and trying to shorten ...
1
vote
1answer
32 views

How to block user agent using htacces? [closed]

i have seen lots of answers but everyone mentions converting user agent into regex format. I dont know how to do. Please help me create htaccess rules to block the user agents below. Anyone can help ...
0
votes
0answers
151 views

How to fix .htaccess error? Keeps asking for authentication

I'm setting up basic http authentication for my subdomain dev Laravel site with .htaccess and .htpasswd. First, I created my .htpasswd user and password by command htpasswd -bc .htpasswd admin ...
0
votes
1answer
38 views

Add Expires headers in GTmetrix

When I test the performance of my website via GTmetrix.com it says that there are 2 static components without a far-future expiration date. and listed below links. https://www.googletagmanager.com/...
2
votes
3answers
865 views

How do I add the an expires header for external URL components as suggested by GTmetrix and YSlow?

I am trying to decrease the loading time of my website which is hosted in Bluehost. So when I check the performance scores via GTmetrix under YSlow section it mention to "Add expire headers" for four ...
0
votes
0answers
25 views

Does the meta tag no-referrer affect the way htaccess redirects and hot-link prevention process?

Update Now that I know what I didn't know when I posted this question, this questions looks pretty stupid. The answer is no, the no-referrer meta tag does not affect the way htaccess redirects. ...
1
vote
1answer
162 views

How can I change URL Letters from Upper to Lower case in htaccess for a specific folder?

I'm a bit stuck, so thank you for any help! In short I'm trying to convert either of the two examples (I have mod_rewrite from the first to the second already). I only want this to apply to the ...