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
3 views

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

I need some extra codes into my .htaccess what configures this correct http request for https too! <ifmodule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com ...
2
votes
1answer
34 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
52 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
1answer
33 views

Redirect if URL contains /product/ (htaccess) [closed]

I've tried dozens of rules in my htaccess, but none have helped me. I have a website where I want to redirect users to a new page, based on a word in the URL. So https://www.example.com/product/...
0
votes
2answers
34 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
61 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
28 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
29 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
25 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
1answer
38 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
2answers
58 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
24 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
38 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
27 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
51 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
44 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
33 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
23 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
84 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
57 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
265 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
48 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
51 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
177 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
161 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
148 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
90 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
23 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
70 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
105 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
43 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
42 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
65 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
35 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
28 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
45 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
117 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 ...
3
votes
2answers
137 views

How to use X-Robots-Tag to noindex all subdomains (save specific exceptions)?

Google's Robots meta tag and X-Robots-Tag HTTP header specifications page (Practical implementation of X-Robots-Tag with Apache section) gives an example of noindexing certain filetypes, ie: <...
4
votes
1answer
43 views

Whats the correct htaccess line to direct from sub-domain to main domain

We have a blog on a subdomain which needs to be moved to the main domain ie: blog.example.com/post-title to example.com/blog/post-title Do I need to create a redirect match for each individual post/...
0
votes
1answer
101 views

.htaccess Redirect if no sub string found in the URL

Whenever user comes in example.com how to redirect them to example.com/home Note: The current routing/URL paths should work after adding this condition/rule For example: example.com/about-us -> no ...
0
votes
1answer
26 views

.htaccess rewrite rules working on Mac Apache 2.2 but not on CentOS Apache 2.4

I've run into an issue when moving from a test server to a production server. I have a set of .htaccess rules in a file in the public_html site root: #Root directory htaccess RewriteEngine On # ...
0
votes
1answer
26 views

what is url robot search engine when enter to my website [closed]

what is url search engine robots when enter to my website for example i add this code in .htaccess this code just allow google robots read the robots.txt i need to add url ( msn , yahoo , bing ) ...
1
vote
1answer
64 views

Overwriting cookies in htaccess

I run a website in a quite cheap shared hosting environment (LAMP): technically speaking, in this context the only thing I can do is edit one or more htaccess files. Maybe for load balancing purposes,...
2
votes
1answer
61 views

How to have .htaccess display 404.html for child pages

I am working on a website example.com that has an error page example.com/404.html. Here's my entire .htaccess file (Apache): # Forces HTTPS RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(....
-1
votes
1answer
38 views

I cannot do https redirection on my website on .htaccess

Am having a local classified website. I bought SSL for the domain but cannot put https redirect on htaccess since my developer wrote somerule on htaccess to get url for SEO. Can some help for the same....
3
votes
2answers
189 views

.htaccess using HTTP_HOST has one extra extraneous redirect when forcing HTTPS

When I use these lines in my .htaccess file, everything works well: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ https://example.com%{REQUEST_URI} [L,R=301] Then I tried to make it ...
2
votes
1answer
507 views

Redirect URL without lang directory to default language

This: example.com/test/ should redirect to: example.com/en/test/, but: example.com/es/test/ shoudn't redirect. in this case /test/ could be anything, with any number of levels (i.e.: /test/succeeded/ ...
1
vote
1answer
262 views

.htaccess redirect dynamic URL (with numeric ID) to remove “track” from the end

It seems to be easy, but I can't figure out how to solve it, nothing worked for me. I have a dynamic URL like: http://www.example.com/user/46/track and I want to redirect from that URL to http://www....
1
vote
0answers
16 views

Disallow URLs made with mod_rewrite in robots.txts [closed]

Here is my robots.txt file: User-agent: * Disallow: /head.php Disallow: /head/ Disallow: /head Disallow: /header.php Disallow: /header/ Disallow: /header Disallow: /footer.php Disallow: /footer/ ...