Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
2
votes
2answers
165 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
vote
0answers
34 views

HSTS compatible .htaccess redirect from non-www to www that preserves URL path [closed]

UPDATE: The redirect actually does work! The site is a friends site and I was coming up with solutions and sending them to him. Turns out his website is running Joomla. After further troubleshooting ...
0
votes
0answers
21 views

Change of Address, Show Error in site 301 redirection on Google Console

I'm trying to use the Change of Address Tool to move a site to new domain. I've set up 301-redirects for all the pages including the home page. However i'm getting a 'Validation failed Failed one or ...
1
vote
1answer
28 views

.htaccess Rewrite Wordpress Subdirectory without breaking other subdirectories

So I have WordPress installed in /wp/ but I want all WordPress URLs to be rewritten to appear in the root directory. I currently have this working (see below) but I want to change my .htaccess so it ...
1
vote
1answer
26 views

Rewrite URL with ID to one file using .htaccess

I have "home" directory as: /var/www/page I need redirect: /var/www/page/index/product/id/9098890 Where 9098890 is the id of product. to one file: /var/www/page/script/index.php I want ...
2
votes
1answer
43 views

Redirect domain in CPanel without using htaccess so I can delete old domain

I have an old website that is being hosted on Apache/CPanel site. I'm being charged for hosting this site, even though it's being redirected to another site. I'd like to delete the hosting of the ...
0
votes
1answer
44 views

Htaccess 301 Redirect only not working on Windows 8.1

Here's the code: RewriteOptions inherit RewriteCond %{HTTP_HOST} ^old\.olddomain\.example$ [NC] RewriteRule ^ https://newdomain.example%{REQUEST_URI} [R=301,L] # BEGIN WordPress RewriteEngine On ...
2
votes
1answer
45 views

301 redirect with regex: how to match any file at top domain level (not in a subdirectory)?

I need to redirect URLs of all .dmg files at domain's top level to specific folder. By way of example: http://example.com/file.dmg to http://example.com/downloads/file.dmg I can't hard code the domain ...
1
vote
0answers
32 views

Subdomain forward with masking on Bluhost

I am trying to forward with masking a Bluehost subdomain (login.example.com) to another Bluehost subdomain (login.example.ca). I did the following; RewriteEngine On RewriteCond %{HTTP_HOST} ^login....
2
votes
0answers
29 views

Safari prompts for BasicAuth credentials on every request in WordPress admin area, but works fine on the rest of the site

I have a WordPress website which is in development, and is hidden behind a BasicAuth password prompt. My root level .htaccess file: AuthType Basic AuthName "Login Details" AuthUserFile /var/...
0
votes
1answer
35 views

.htaccess file location on server [closed]

Because I am using a shared server (Apache 2.4) and don't have root access, I uploaded an .htaccess file. As best as I can determine, the .htaccess file is not stored in the public_html directory, ...
2
votes
1answer
40 views

Apache mod_rewrite in .htaccess

This should be a simple question. Checked Google but it listed nothing helpful. I use WP on one of my sites and it already generates a mod_rewrite section with: <IfModule mod_rewrite.c> ...
2
votes
1answer
36 views

How can I limit .htaccess to current directory scope only?

I have something like this: Options -Indexes RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA] Order deny,allow ...
1
vote
1answer
37 views

Internal Server Error caused by rewriting [closed]

Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(.*)$ $1.html [NC,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{...
1
vote
0answers
26 views

Remove PHP extension from URLs such that the URLs work with or without a trailing slash

My directory structure is - Assets - Dashboard - index.php - account.php index.php about.php verify.php What I basically want it to be: Remove the .php extension for example http://example.org/...
1
vote
2answers
44 views

How to redirect to same page for changing language via .htaccess config?

How to redirect to same page for changing language via .htaccess config? For example example.com/some-page/en example.com/some-page/de
1
vote
1answer
48 views

Apache Rewrite Rule www to non-www + http to https + add trailing slash

I really need the following 3 features of my website: www to non-www HTTP to HTTPS force trailing slash at the end of the URLs I have a current implementation but I face a very bad bug. When I ...
0
votes
1answer
32 views

How to set default page, but keep URL extension?

I am trying to set {mydomain}/forum to be the default URL that people are brought to when they go to {mydomain}. I have this working, as in my .htaccess I wrote DirectoryIndex index.php?route=/forum/ (...
3
votes
1answer
27 views

Drop and expire all cookies with a specific prefix

We're running a WordPress site with WooCommerce. A third party plugin was injecting (sbjs_*) cookies into our site to track purchases and provide us with additional reporting. Unfortunately, something'...
2
votes
1answer
57 views

Converting nearly 200 redirects into redirectmatches

I have close to 200 redirects that I would I to bring down to maybe a few dozen. Most look like the following. Redirect permanent /Fandom/Fictional_artifacts.pl /Fandom/index.pl?page=Fictional+...
3
votes
1answer
93 views

htaccess redirect root domain to subdomain with exceptions

i m using wordpress and want to redirect my root domain to a new subdomain and ignore urls that contains a certain string http://www.example.com/post.html To http://subdomain.example.com/post.html ...
2
votes
1answer
37 views

How do I redirect traffic only if being accessed from a specific port?

My website, https://coolkids.gq, has a Minecraft server hosted on it as well as a web server. It hosts both Bedrock and Java versions of Minecraft (unrelated) and I’ve figured out how to do the Java ...
1
vote
2answers
49 views

How to redirect some URLs to another local port with .htaccess?

I have the .htaccess file in the root public_html directory. It contains the following: Options -Indexes Redirect / /dali RewriteEngine on RewriteRule ^api/(.*[^/])/?$ http://%{HTTP_HOST}:5000/$1 [R=...
1
vote
1answer
27 views

convert htaccess to nginx [closed]

I want to convert this htaccess code to nginx. <ifModule mod_rewrite.c> RewriteEngine On ## Application Handler RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-...
1
vote
1answer
76 views

How to block access with certain string in the URL?

My site used to have a SEO hack. Although I have reinstalled the website, the attacker is still trying to access these URLs via Google or direct: /404.html?page=/wp-content/uploads/2020/03/... /wp-...
2
votes
1answer
41 views

Configure Apache to show a custom page rather than my host's default when a user cancels logging in via basic authentication

I have a protected directory on an hosted IONOS server. It correctly works when the correct credentials are entered, but when a user hits cancel, it redirects that user to the hosting provider's promo ...
1
vote
2answers
36 views

All pages are not being redirected to HTTPS when accessed using HTTP

I'm running a Wordpress blog that has an issue with HTTPS redirect. Except home page, no other URL is being redirected to HTTPS if you visit via HTTP. I want to redirect all HTTP traffic to HTTPS. ...
2
votes
1answer
67 views

How to disable .htaccess file using JavaScript?

By the way, the .htaccess was already enabled to my main directory. Is there any way to disable it using JavaScript? to my client-side? I was just curious about how my files are being secured. Thanks ...
3
votes
2answers
114 views

Can't get rewriterule substitution to work

I am trying to use Apache rewrite to turn something like https://www.example.com/sub/?v1=123&v2=456 into https://www.example.com/sub/?v1=789&v2=456 i.e. changing v1 to a specific value ...
2
votes
1answer
49 views

Can I create a keyword subdirectory for my home page to help SEO?

My website consists of an English-language Homepage (my index.html file), and a German and Russian translation of this page (de.html + ru.html), which are accessible through a button on the top-right. ...
-1
votes
1answer
18 views

Redirect https alias to http main domain (it is showing no private connection error)

Redirect https alias to http main domain (it is showing no private connection error) I have one domain alias www.domain2.example The main domain is www.domain1.example When someone enters to www....
0
votes
1answer
620 views

How to manually add expire header for google fonts css files? [duplicate]

i am trying to boost my website, but when i look it on gmetrix it says following statement There are 6 static components without a far-future expiration date. https://fonts.googleapis.com/css?...
5
votes
1answer
86 views

Is it good to go live with 302 first and then change it to 301 if everything works perfect

I am in the process of removing duplicate content (or URLs) issue on my website. There are hundreds of similar content links on my website where both URLs one without trailing slash and one with ...
2
votes
1answer
40 views

Duplicate content after moving from http to https

I move my wordpress blog from "http" to "https". I generate a sitemap that contains canonical urls with "https" and submit it to GSC. I used "rel=canonical" tag in all blog post urls. I also implement ...
2
votes
1answer
93 views

1&1 Ionos hijacking my error pages

I have a website hosted by ionos (formerly 1&1), they have an annoying "feature" (*) whereby an incorrect page request is hijacked and sent to a third party. The source code for the page I'm ...
1
vote
1answer
26 views

Sharing .htaccess files between directories on a server

I have a webserver with thousands of directories. Some need to be internal only, some need to reference specific IP addresses, some are public. These .htaccess files change from time to time with IP ...
1
vote
1answer
30 views

how fix rewrite rule conflict

I am using following rewrite rule and its working fine : 1) RewriteRule ^([^/]*)/?([^/]*)/?([^/]*)/$ estates1.php?pageNum_Clusterb=$3&estname=$1&location=$2 [L] but when add second code in ...
2
votes
1answer
36 views

htaccess Redirect Using Regex

I have 2 redirects that work fine: Redirect 301 /namedeal/ca_domain_name.php /namedeal/cheap_domain_name.php Redirect 301 /namedeal/ws_domain_name.php /namedeal/cheap_domain_name.php I want to be ...
1
vote
0answers
14 views

Redirecting to new domain page by page [closed]

I'm trying to redirect a domain to another one. Because of SEO concerns I've made a list of all the pages indexed in Google and for each one I decided where to redirect to. My .htaccess looks like ...
1
vote
1answer
17 views

.htaccess redirect to “410 Gone” status for URLs containg one letter + word “shop” after domain

After I recovered Drupal 7 site from malware attack I end up with lot of links pointing to (previously) spam content like this: https://www.example.com/lshop/puma-rihanna-c-449/?zenid=...
1
vote
1answer
43 views

change DirectoryIndex file for subdomain

I want two languages on my website - one french-specific website, and one in english for broader purposes (and no automatic translation). For maintenance reasons, I'd like to not duplicate images and ...
1
vote
1answer
84 views

.htaccess to redirect URL with specific query-string, to a different domain, maintaining the query-string

What I wish to do I have one particular URL I need to redirect using .htaccess, based on a specific value being present in the query-string. A 301 permanent redirect header being sent to browser (...
2
votes
2answers
80 views

How to Confirm that My Site is Not Indexed?

I want to prevent my site from being indexed and listed by Google. So I follow the instructions in https://yoast.com/prevent-site-being-indexed/ and add: Header set X-Robots-Tag "noindex, nofollow" ...
2
votes
1answer
39 views

Redirect URL via htaccess unique destination for subdirectories

I am trying to redirect URLs of a old Perch CMS to a custom CMS like this: Redirect /sites/praxis/ http://example.com/_Unser_Cabinet Redirect /sites/praxis/sites/chiropraktik http://example.com/...
1
vote
1answer
71 views

htaccess 404 code does not trap an incorrect URL path (with a / in the string [duplicate]

I have a simple 404 redirect in my .htaccess file: ErrorDocument 401 /404.htm ErrorDocument 404 /404.htm RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://hypnosis-retreat....
1
vote
0answers
29 views

Website was not redirect from non www to https+www

I'm currently doing www+https redirection where I hope that my website able to redirect from http://example.com to https://www.example.com but it does not work even I have added redirection in ....
1
vote
0answers
14 views

SEO Rewrite , URI Without .php Extension To file [duplicate]

I have website with this output Link : https://domain1.net/estates.php?estname=XXXX&location=YYYYY I want change it to : https://domain1.net/XXXXX/YYYYY I try it with following rewrite rule : ...
2
votes
1answer
30 views

Using .htaccess to map a random path to a private directory

I am trying to implement a zero downtime deploy strategy for a static website using an .htaccess file. I'd like to access at http://example.com/__staging__ the staging enviroinment redirecting ...
3
votes
1answer
44 views

How can I allow hotlinking between my own sites

I have several sites hosted on a Bluehost server. I would like my sites to be able to use each others' images. In other words, I want to let my sites hotlink images from each other. There is an ...
2
votes
1answer
37 views

Apache .htaccess Redirect and RedirectPermanent directives do nothing

I am trying to do a very simple redirect for an entire web site using instructions from sites like this and this, and several others that say the same thing. I am using Apache. My .htaccess file ...

1
2 3 4 5
31