Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
2
votes
2answers
166 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 ...
3
votes
1answer
91 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
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 ...
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 ...
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 ...
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 ...
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 ...
5
votes
1answer
538 views

301 redirect away from content that is served with a reverse proxy to prevent duplicate content

I am currently struggling to resolve an issue stemming from a reverse proxy. We are running a reverse proxy from page.example.com to example.com/page/ . This original subdomain content is generated ...
1
vote
1answer
1k views

RewriteCond %{HTTPS} !=on is not working even though RewriteCond %{SERVER_PORT} !^443$ works

I have a requirement to check for non HTTPS URLs in htaccess. My understanding is that RewriteCond %{HTTPS} !=on will match all URLs that are not HTTPS. But upon testing, I find RewriteCond %{HTTPS} !...
1
vote
1answer
76 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/...
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 ...
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 %{...
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
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
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
5
votes
2answers
13k views

.htaccess how to redirect the contents of a directory to a subdirectory

I'm trying to redirect the contents of a directory that is placed at the top level of my website, to a subdirectory one level deep. I also need to exclude two files and a folder. Nothing I've tried so ...
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....
4
votes
2answers
7k views

How to stop access of a PHP file from other sites

I read somewhere about hot linking of images. Preventing image hot linking helps to stop bandwidth theft from your site. Would it work for a PHP file? In my case, I am using a PHP file to generate ...
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
116 views

What should I do about penalized websites that have been 301 redirected to mine?

Someone is doing a negative SEO attack on my site 301 redirecting toxic sites to my site. I have done research and nobody online seems to have an answer. Would disavowing the domain doing the 301 ...
2
votes
1answer
37 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 ...
2
votes
1answer
996 views

How to fix this 404 soft error?

I have a static HTML website. www.example.com/?12345 (this page doesn't exist) redirects to www.example.com and www.example.com/page.html?12345 redirects to www.example.com/page.html. I don't know ...
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
1answer
59 views

Using htaccess to redirect 301 for domain change

I am currently moving a domain from one to the other, this is not an HTTPS move but rather a move from exampleone.co.uk to exampletwo.co.uk. I am using this code: <IfModule mod_rewrite.c> ...
1
vote
1answer
391 views

htaccess force HTTPS to main domain and all subdomains

I have a server with a main domain, and several subdomains. There is independent wordpress sites/installs on each of the subdomains, and also one on the main domain. (I know about multisite, but they'...
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'...
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=...
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+...
2
votes
2answers
4k views

mod_rewrite ignore Stylesheet and JavaScript

I have a mod_rewrite to allow example.com/location as example.com/?page=location RewriteEngine On RewriteBase / RewriteCond %{QUERY_STRING} !^page RewriteRule ^(.*)/?$ /?page=$1 [L] But how do I ...
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 ...
4
votes
1answer
2k views

RewriteRule doesn't work for a CSS file and a document when a RewriteCondition is added to test if a name value parameter is in the query string

I'm trying to change the DocumentRoot to subfolder through .htaccess. This works well... RewriteCond %{REQUEST_URI} !subfolder/ RewriteRule ^(.*)$ /subfolder/$1 ...however, I only want to do this ...
3
votes
1answer
3k views

Can .htaccess 301 redirects work with encoded characters?

I have an old site with titles in the URL for SEO, but it has URL encoded characters than transliterated Latin characters. Like %20 instead of space character and many other non-Latin characters. The ...
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
78 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-...
3
votes
1answer
43 views

301 redirect rewrite query string in .htaccess [duplicate]

I am trying to perform a 301 redirect in .htaccess and I need to remove the query string ?view=full. Here is what I have that is not working: RewriteRule ^/contact/?view=full$ /contact/ [R=301,L] I ...
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 ...
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
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. ...
5
votes
1answer
8k views

.htaccess syntax multiple RewriteEngine on

I'm learning to maintain my own WP site. After a lot of reading I ended up with my "complete" htaccess file that looks something like this DirectoryIndex index.php # Disable directory listings ...
1
vote
1answer
935 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....
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 ...
3
votes
3answers
11k 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 ...
-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....
2
votes
1answer
15k views

How can I get a regular expression to only match an empty string? (In a .htaccess file)

I try to make a regular expression in a .htaccess file, that matches only an empty string. I have tried many things, but it seems like it’s impossible. For example, I tried ^$, but it's looking for ""...

1
2 3 4 5
31