Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

0
votes
0answers
21 views

.htaccess clean url to GET variable with WordPress

I'm struggling to get a .htaccess rule to work. I'm trying to cleanup a URL for a WordPress site. Instead of /illustration?rid=123, I'd like /illustration/123. I've tried solutions from many of the ...
0
votes
1answer
28 views

Redirect to remove everything after the second slash (first directory)

I'm trying to redirect a lot of pages on a website I own. There are a few pages indexed and I need to fix them for example: /vloerafwerking/projecttapijt/raamafwerking/ needs to go to /vloerafwerking/...
1
vote
1answer
11 views

Don't allow access to example.com/image/pic.jpg using htaccess

I have two domains for the same website. example.com and example2.com . I don't want the /image/pic.jpg to be accessible for the example.com It means, if someone try to visit example.com/image/pic....
1
vote
1answer
33 views

Add Trailing Slash for certain page types

I would like to add a trailing slash for certain static page types like .html, .asp and .pdf. I tried the following code in .htaccess but it is adding a trailing slash to all types of links. # Force ...
0
votes
0answers
12 views

How to enable .htaccess Gzip? [duplicate]

#Gzip <ifmodule mod_deflate.c> # compress text, html, javascript, css, xml: AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/...
0
votes
0answers
16 views

Redirect IP address to domain using .htaccess [duplicate]

I tried the following .htaccess code to redirect the IP address of my VPS server to my domain, but despite of all efforts it keeps resulting in a 404 error: RewriteEngine on RewriteCond %{HTTP_HOST} ^...
1
vote
1answer
24 views

htaccess rule doesn't work - NET::ERR_CERT_COMMON_NAME_INVALID

This URL: https://mqgmodas.com/rebajas/ Into the .htaccess I have: Redirect 301 https://mqgmodas.com/rebajas/ https://masqguapas.com/rebajas/ Also I have a redirection in my control panel saying ...
0
votes
0answers
25 views

Edit htaccess file to remove the slash at the end without disturbing https settings [duplicate]

My website URL has a slash at its end and appears like this https://mywebsite.com/ Since search engine reads https://mywebsite.com/ and https://mywebsite.com as two different URLs, I want to ...
3
votes
0answers
31 views

Why are my HTML resources re-downloading despite having an expiration date a month in the future?

I have set the expiration information for my resources in the .htaccess file as shown below: <IfModule mod_expires.c> ExpiresActive on ExpiresByType image/jpeg "access plus 1 month" ...
1
vote
1answer
36 views

htaccess category seo url redirecting to 404 page in localhost [closed]

I am trying to edit my htaccess. All urls working fine on server, but same htaccess setup redirecting category/cat_name/ url to 404 page without giving any error. all other urls working fine accept ...
2
votes
1answer
42 views

Return 410 gone status code for URLs containing same characters in .htaccess

My website was hit by the pharma spam attack which created hundreds of URLs, all of which contain the last 5 characters -1234.pdf. So that Google and other search engines will remove these quicker, ...
1
vote
1answer
25 views

how to redirect lower case to upercase

I have a WordPress blog and I made subfolder like this https://example.com/Tourism but when I open this URL with lowercase "t" it shows me 404 not found error: https://example.com/tourism this ...
2
votes
1answer
37 views

Redirecting /page/*/ to the home page in .htaccess

My problem is that my homepage exists on https://www.example.com/page/2/, /3/, /4/ and so on, it still exists on /1000/. Same duplicate page versions exists on /about and and /contact page of my site. ...
1
vote
1answer
54 views

.htaccess rewrite conditions for https:// pre tag subdomains

I need some extra code in my .htaccess file that configures this HTTP request for HTTPS too! <ifmodule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^(.*)\.example\.com RewriteRule ^...
2
votes
1answer
74 views

.htaccess redirect with all parameters

I have a simple rule in the .htaccess file, to redirect all requests to inwork.php: RewriteRule .* php/inwork.php?refpage=%{REQUEST_URI} [L] But all parameters are missing. For the request http://...
2
votes
1answer
88 views

.htaccess - How to properly disable the execution of scripts in a folder?

I have this folder path: pulic_html/user/269851516/in the folder /user/ i have many subfolders that is created when the user create a account, and they can upload avatars to this folder, i want to ...
0
votes
2answers
40 views

htaccess - Blocking IPs - Hidden and / or spoofing(?)

.About a month ago my website was hacked. I was alerted to that by Google Adwords because a random scan of my site indicated that it had inappropriate content and / or links to inappropriate content ...
1
vote
2answers
74 views

How secure is an .htaccess file?

I am creating a new website and I want to make it as secure as possible. I was preparing to do some things with .htaccess and I'm semi-concerned about the security level it provides. Can someone (ex: ...
1
vote
1answer
31 views

How is the mapping done from …/script.php?one,1 to …/script/one/2?

There is a PHP script which evaluates one or two parameters via QUERY_STRING. This script should process the parameters via QUERY_PATH. The PHP file type should be omitted. Request of the form https:/...
1
vote
1answer
50 views

How to redirect all url to https except one?

# Go to https if not on firmware RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} !^/firmware$ [NC] RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] # Go to http if you are on firmware ...
2
votes
1answer
27 views

Problem with [R=301]

Some of my RewriteRules don't work if i put the [R=301]. why this don't work? RewriteRule ^sitemap\.xml$ sitemap.php [R=301,L] It shows a Forbidden error when i try to access the URL https://example....
0
votes
2answers
47 views

301 redirect in the htaccess file issues

This is driving me crazy, can anybody tell me why this 301 redirect does not work. I just get a 404 error with the old /about page. Here is the code for info: {ENV:WPR_SSL}.html%{ENV:WPR_ENC}" -f ...
2
votes
1answer
31 views

Rewriterule redirects to URL and shows different URL?

I've a website hosted on an Apache server which hosts other domains. Therefore, I can't access the Apache configuration. On our website, I've several domains. For one of them (domain example.com), I'...
1
vote
3answers
75 views

When I have multiple .htaccess files between several sites, which is the active one?

I have 4 sites hosted with the same ISP. The sites were modified endless times, and now, I have several .htaccess files. One of the is at the main root. The others are spread in different places. For ...
1
vote
0answers
28 views

Infinite redirect loop with IIS 8.5 Drupal

After configuring my website, i stuck in a infinite redirect loop. I have 6 domains, example.com is main domain. example1.com, ..., example5.com are forwarding to example.com. Doesn't matter which ...
3
votes
1answer
42 views

Multiple rules to rewrite the url

Why both rules don't work together and how can i fix it? Only the first one works... I think that there's a conflict between the two rules, but i did not found a solution yet ?p= is the querystring i ...
1
vote
0answers
30 views

How to allow Google fonts to be cached for more than one day?

I tried this code below, but I still see the message on Google Insights that the fonts have a expiration of 1d. AddType application/vnd.ms-fontobject .eot AddType application/x-font-ttf .ttf AddType ...
3
votes
1answer
61 views

Hotlink Protection compatible with Google AMP pages

I'm trying to create HTACCESS Hotlink Protection on my site but I'd like all Google top level domains (.com., .co.in, .co.uk, etc) to be able to access my files, so that visitors to the Google AMP ...
3
votes
1answer
51 views

Non WWW redirect to WWW and non SSL to SSL - htaccess

I'm trying to redirect my Wordpress site from non www to WWW and non SSL to SSL permamently. Here's the code I'm using: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ https://%{...
3
votes
1answer
34 views

Can I block Tor users from sending spam on my form?

Can I use .htaccess to kill any message coming from a Tor IP, or should I make a script on my mailer? I've got $IP = $_SERVER['REMOTE_HOST'] ?: gethostbyaddr($_SERVER['REMOTE_ADDR']); and I checked ...
1
vote
1answer
24 views

.htaccess - redirect the contents of a subdirectory of old domain to new domain (WordPress) [duplicate]

I have problems with the redirection of my old website to our new website under a new domain. The old website was created with Wordpress and the simple redirect 301 was successful. However, some pages ...
1
vote
1answer
103 views

Convert Base64 in .htaccess

My Line is as under in .htaccess Header set Content-Security-Policy "script-src 'self' 'nonce-%{UNIQUE_ID}e'; style-src 'self' 'nonce-%{UNIQUE_ID}e';" Please let me know how to convert %{UNIQUE_ID}e ...
2
votes
2answers
74 views

How to show 410 Gone status for subdomains that are already been deleted

I bought an auctioned domain to build my new project, from my analysis with Ahrefs, people that were behind this domain had a subdomain called "forum" for their forum, and somehow they didn't know how ...
1
vote
1answer
284 views

RewriteEngine .htaccess rules end up redirecting to example.net/https:/example.net

I'm starting to learn about the Apache .htaccess and I have some issues in my website... RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} RewriteCond %{...
3
votes
1answer
53 views

How to redirect a specific search result using .htaccess

When searching for "interesting people" the search results page of my website is https://example.com/?s=interesting+people&submit.x=0&submit.y=0 Instead of displaying that search results page ...
2
votes
2answers
52 views

Installing WordPress with /wp path leads to redirect loop when index.html redirects to a shopping cart

So on my site, my shopping cart is located at example.com/zc2 I use this .htaccess file RewriteEngine On Redirect /index.html example.com/zc2/ So that anyone that lands on example.com will be ...
2
votes
1answer
379 views

Htaccess redirect pages from subfolder to root directory while preserving any query string

I have moved pages in various sub directories to the root directory and want to set up a 301 redirect for each page and keep any query string that might be present. For example: www.example.com/...
-1
votes
1answer
245 views

How to remove trailing slash from my root URL in htaccess?

I've tried several ways to remove the trailing slash from my URL in .htaccess and nothing worked but now even my URL can't be found because now it has a slash. Here is what my .htaccess looks like. I ...
2
votes
2answers
286 views

Can .htaccess be used to set file permissions?

Is it possible to define file type permissions through .htaccess? I have a site that uses .pl and .cgi scripts which require 0755 CHMOD. The shared server setting is apparently geared for WordPress ...
4
votes
1answer
146 views

Moved images to another folder - need help with htaccess rewrite rule for png

I had to move my image folder. Before it was example.com/shoplogo/(name*).png now its example.com/shop-logo/(name*).png just stuck with the rewrite rule :-(.
1
vote
1answer
27 views

Change max_input_time when you don't have access to php.ini file

I am using freehosting website to host my wordpress blog. However, while trying to use duplicator plugin to migrate my blog it asks me to change the max_input_time value to 0 I don't see php.ini file ...
0
votes
1answer
74 views

How to migrate from HTTP and HTTPS old sub domain to HTTPS root new domain in htaccess with least SEO risks?

Looking for the best site migration strategy for SEO, which consider these specific combinations of elements and challenges: *note: site is in Wordpress. Htaccess redirect code to go from sub ...
2
votes
1answer
170 views

Block blank user-agents bots but make exception for ip address possible?

I have the following in my .htaccess file on website2, but when my other website on website1 makes requests to website2 it is blocked because the server user-agent is blank. Is there are a way to ...
6
votes
2answers
47 views

In .htaccess files, is there any difference at all between “!=on” and “off”

I’m trying to better understand Apache’s use of a binary attribute. In an .htaccess file with the code # Check if HTTPS is 𝗻𝗼𝘁 𝗼𝗻 RewriteCond %{HTTPS} !=on Is there more processing occurring&#...
2
votes
0answers
45 views

Local browser caching not working due to .htaccess rules

All the JavaScript files hosted from my server are not being cached - just those from 3rd party CDNs. The information on caching is bountiful, but I've been unable to create something that works. I'...
2
votes
2answers
68 views

Wordpress htaccess redirect from http to https

Currently I use this rule on my WordPress .htaccess file to redirect HTTP to HTTPS: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{...
2
votes
0answers
46 views

htaccess requesting password twice

I am using .htaccess to password-protect a directory. When users attempt to log in, they enter a username and password, and are refused access --- but if they try a second time, they get in just fine ...
2
votes
1answer
29 views

.htaccess to redirect domain1 to domain2

I currently have a .htaccess file with the current lines to force HTTPS: RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] My main domain is ...
1
vote
0answers
49 views

Combining password protection and redirects in .htaccess file

I'm a designer who developed a simple site with HTML and CSS. I'm completely new to .htaccess so it's not surprising I'm struggling to get the file to work as I want. Problem 1: I want to password ...
4
votes
1answer
163 views

How can I redirect all PDF files with file names that don't start with “public” to the home page?

I would like to disable direct access to all PDF files except those with a public- prefix on the beginning on the file name (e.g., public-samplepdf.pdf) so they can be viewed in public. I'd like to ...