Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
3
votes
1answer
36 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
146 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,...
1
vote
1answer
40 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
1answer
266 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....
3
votes
2answers
396 views

Prevent Google Indexing SubDomains

I have cPanel Hosting with only 1 IP. I'm in the process of pointing all my TLDs to this server. I have created Addon Domains and all the folders from which it creates are located in sub directories ...
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
0answers
45 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
13 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://...
1
vote
1answer
838 views

.htaccess file to implement multiple redirects

I have a dynamic site and from .htaccess file creating clean URLs: RewriteCond %{REQUEST_URI} !(\.png|\.jpg|\.gif|\.jpeg|\.bmp)$ RewriteRule ^([a-zA-Z0-9_\-\+\ ]+)$ flight.php?flights=$1&slug=$1 ...
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 ...
0
votes
0answers
246 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 ...
4
votes
1answer
54 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
174 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
32 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,...
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 ...
2
votes
1answer
72 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 ...
3
votes
1answer
1k views

Avoid 301 redirect in cdn.domain.mx

I have a domain with a .htaccess redirection problem. The active CDN the URL should be: cdn.domain.mx/images/test.png but redirects: cdn.domain.mx/images/something.png -> www.domain.mx/images/...
3
votes
1answer
48 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
895 views

Redirecting all subdirectories of a folder via htaccess [duplicate]

I've searched around and haven't found this specific question asked. I need to redirect all the 'subfolders' of a directory to the parent directory. For example, the parent directory is example.tld/...
3
votes
3answers
2k views

How to remove /index.html

How to make redirect /index.html -> / in Apache? Redirect /index.html http://domain-name.com/ Is causeing infinite loop when opening home page.
2
votes
2answers
186 views

Rewrite Issue on index.html

I have index.html on my html_directory on my website also I entered a rule as follows: RewriteRule ^index.html$ newindex.php It seems requests to my site is routing to my index.html file , my ...
8
votes
2answers
6k views

.htaccess redirect url without trailing slashes

In my htaccess I have some rewrited urls like these: RewriteRule ^first-page$ /subdir/page.php?id_page=1 [QSA,L] RewriteRule ^second-page$ /subdir/page.php?id_page=2 [QSA,L] RewriteRule ^third-page$ /...
4
votes
1answer
39 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
37 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
571 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 ...
4
votes
1answer
91 views

Redirect domain name to a specific page

I have theses domain names installed: Main domain name: www.example.com Others domains: www.example.org www.example.fr www.animals.example I first made a rule on my .htaccess to redirect all ...
2
votes
1answer
27 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 ...
1
vote
2answers
96 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 ...
11
votes
4answers
3k views

Can the files robots.txt and sitemap.xml be dynamic through an .htaccess redirect?

I have a multilanguage and multidomain site. It runs through a unique CMS installation (Drupal), so I have a single root directory. So if I have a static robots.txt, there I only can show the files ...
3
votes
1answer
235 views

Redirect 301 for Apache Sub directory and query string combination

I am getting 404 errors in Google Search Console for URLs like the following: http://www.example.com/newsite12121212121212/eg/st_tour/perma/ http://www.example.com/newsite12121212121212/eg/...
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
1answer
373 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 ...
1
vote
3answers
2k 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 ...
2
votes
1answer
36 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/...
2
votes
3answers
117 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 ...
11
votes
6answers
8k views

Forcing SSL and www in .htaccess

I'm looking for a way to force SSL and www. I've been able to force both separately but together I keep running into redirection issues. The following code works when handling a URL in this format: ...
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 ...
2
votes
1answer
250 views

How to form redirect or rewrite where query string contains portion I want to extract to new query string

I've transferred an old custom-made site to Mediawiki and I have many internal and external links to my old pages that I want to redirect to the appropriate wiki page. There are many links to the ...
1
vote
1answer
55 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
248 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
69 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/...
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
38 views

Old WordPress pagination URLs still show first page of content and Google indexes some of them

We use self-hosted Wordpress and earlier we were using paginated posts in our article like. www.example.com/some-article.html www.example.com/some-article.html/2 www.example.com/some-article.html/3 ...
1
vote
1answer
58 views

Stop URL tag redirection to my homepage

I'm trying to find a way to stop tag redirections to the homepage so that https://example.com/?something stops redirecting to https://example.com. Similarly, any URL which is followed by a question ...
2
votes
1answer
18 views

Apache redirection rules for wordpress sites

I want to redirect http://www.example.com/findyourname/ to http://www.newexample.com./findyourname/ http://www.example.com is a wordpress site , so when accessing http://www.example.com/findyourname/ ...
1
vote
2answers
88 views

Issues with redirect rules to redirect all URLs except one page

I need to add following Apache redirect rules to .htaccess: http://www.example.com to be redirected to http://www.onemoreexample.com but http://www.example.com/support should not be redirected. To ...
1
vote
1answer
46 views

Researching .htaccess Syntax

In my template .htaccess file I have been copying and pasteing alot of rules and researching .htaccess for around 2 weeks in an attempt to try and better understand the syntax, different modules & ...
1
vote
2answers
2k views

Where to place 301 redirects in the .htaccess file on a WordPress site

I edited my .htaccess file earlier to redirect from www version to non-www, and it is working correctly. However, now I have some page redirects I need to do. I am looking at the .htaccess file, and I ...
16
votes
2answers
79k views

Font blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin'

we are experiencing this error in Google Chrome. We thought everything was set-up correct. But maybe not? Font from origin http://skin.cdn.com has been blocked from loading by Cross-Origin ...
2
votes
1answer
23 views

Redirect root to subdirectory of current year if this exists, otherwise to a previous year that does exist

This kind of htaccess code is a little complex for me as I'm just beginning to understand redirects with htaccess. Could someone help me with this? Thanks in advanced.