Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
2
votes
1answer
26 views

Cookies for www and non-www different

I just discovered that cookies for www and non-www are different. I now understand that the browser treats example.com and www.example.com as two different domains. In detail, how can I assure that ...
8
votes
2answers
2k views

I bought a domain to do a 301 Redirect - do I need to host that domain?

I'm competent with setting up records for domains, things like CNAME, A Records, etc - but what about if I just want to redirect it? Do I "have to" do this using a .htaccess file on a host? ...
2
votes
0answers
32 views

Prevent search engines from crawling and indexing all domains and subdomains set up under an Apache server

My company is renting a CentOS server, with one main domain and ~30 subdomains (the number varies, but it's usually around 30) hosted on it. The subdomains themselves are used for various purposes (...
2
votes
1answer
155 views

Redirect from index.html to its directory using .htaccess?

For each page of my website, it is named index.html and stored inside a folder of the name of the page. example.com/ serves example.com/index.html example.com/about/ serves example.com/about/index....
1
vote
1answer
20 views

Subdomain rewrites without using certs that don't support sub domain affecting

I am using LetsEncrypt to generate and renew my certs for my website. Unfortunately, it does not support subdomains. Having said that, I have a ton of rewrite rules that work fine. For example: ...
1
vote
1answer
46 views

Htaccess - replacing a query string with a numeric value

I don't know why but this htaccess item doesn't work for me. I have something like this after update user profile public/user_profile/show_user.html?id=4 and I want to have public/user_profile/...
2
votes
1answer
35 views

How can I rewrite all Files to the Index Folder and also Remove the Extensions

I've been looking for a solution for a few hours now, and I'm struggling to understand why the Regex doesn't act like Regex... If you just try to match a letter, it doesn't match a letter, and I can't ...
2
votes
1answer
29 views

Apache doesn't redirect subfolders

I'm having trouble configuring my Apache server through the .htaccess file. I want to redirect all request from my domain (example.com, www.example.com, example.com/folder1/folder2) to my new domain (...
1
vote
1answer
50 views

PHP Undefined index: REDIRECT_STATUS - error 404

Custom 404 page in PHP using .htaccess file. If page dosen't exist redirect to error.php. I don't know why but it doesn't work. Notice: Undefined index: REDIRECT_STATUS on line 2 <?php $error = $...
1
vote
1answer
58 views

Htaccess RewriteCond based on environment variable

I find apache very unfriendly. Anyway. I have this: RewriteRule (.*) - [QSA,E=DOMAIN_NAME:localhost.com] This doesn't redirect, which is fine: RewriteCond "www.%{ENV:DOMAIN_NAME}" "!=...
2
votes
2answers
53 views

Point all to index.php conflict with a private directory

Here is my website structure (root): private public .htaccess index.php The htaccess file contains: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ /index.php [L] Having this said,...
1
vote
1answer
19 views

What's the difference between access and access plus in ExpiresByType directive?

I have seen: ExpiresByType image/jpg "access 1 year" But also: ExpiresByType image/jpg "access plus 1 year" So, what's the difference between those two lines ?
1
vote
1answer
16 views

What types of files does ExpiresDefault include?

I have: ExpiresActive On ExpiresByType image/jpg "access 1 years" ExpiresByType image/jpeg "access 1 year" ExpiresByType image/png "access 1 year" ExpiresByType image/gif ...
1
vote
2answers
30 views

How ExpiresByType and Header set Cache-Control works together?

I have: ExpiresActive On ExpiresByType image/jpg "access 2 years" And let's say: <filesMatch ".(jpg|jpeg|png|gif)$"> Header set Cache-Control "max-age=31536000, ...
3
votes
1answer
96 views

Rewrite wildcard rule to redirect images that works with HTTP, HTTPS and Firefox HTTPS-Only mode

This set of rules causes the nolinks.jpg image to appear if anyone tries to link directly to an image from a remote site. It is working well but with the latest Firefox, the browser is forced to ...
2
votes
0answers
22 views

Problem with URL path when I applied SEO friendly URL [duplicate]

I was working on PHP project and making SEO friendly URL Like, OLD : http://example.com/list_product?q=men-top-wear New : http://example.com/list_product/men-top-wear Here is my .htaccess file: ...
1
vote
0answers
21 views

Understanding mod_expires apache module [closed]

Working with htaccess is a new capitol for me. I have already read about mod_expires here https://httpd.apache.org/docs/current/mod/mod_expires.htm, but I'm stil confused. I have the next code from ...
2
votes
0answers
28 views

Is ifModule in htaccess a bad practice? [duplicate]

Can someone give me a good reason why users are using ifmodule in their htaccess ? <IfModule mod_headers.c> Header set Cache-Control "max-age=290304000, public" </IfModule> # ...
1
vote
0answers
50 views

Understanding htaccess cache rules [closed]

Ok. I've read a lot and I understand almost nothing. I talk about cache, and I don't know any cache system that is interested in keeping my files, for me, and for free. And, as I read, there are ...
3
votes
1answer
52 views

What will happen if I have two htaccess/robots.txt files in two directories?

I think there is (or I did something wrong) on my site: I installed a pre-made WordPress theme and normally they are installed as 'quick-install-package' with duplicator. When I installed the package, ...
4
votes
0answers
63 views

Upgrading my website to be multilanguage, is this use of cannonical code the right way?

I have a good SE ranked webpage written in dutch(=nl) and I have just upgraded my site to be in french too. So I've created subdirectories for NL en FR, but my root/index is now exactly the same as my ...
4
votes
1answer
65 views

Rewriting a folder name using .htaccess doesn't want to work

I am wondering, why folder renaming doesn't work. RewriteRule ^pl/(.*) public/$1 Let's say I have a URL like: example.com/public/index.html Now I want to rewrite the URL to example.com/pl/index.html ...
2
votes
2answers
43 views

Excluding homepage from Rewrite rules in htaccess

I would like to have this new prerendering service I'm using NOT apply its magic to the homepage and basically only to pages that begin with https://thechartcast.com/episodes/. Below is the relevant ...
1
vote
1answer
147 views

How to prevent a specific PDF file from being indexed by search engines in Wordpress?

In a wordpress multisite installation, I would like to block indexing of a specific pdf file using HTTP X-Robots-Tag response header using htaccess file. Any of the indications found in previous ...
0
votes
0answers
47 views

How To Fix 404 Errors On An Entire Site?

I have a PPC l client who recently re-designed their e-commerce site. The only problem is that every single old link that they had before is now a 404 error. They had a fairly healthy organic ranking ...
2
votes
1answer
27 views

htacces rules for mobile and desktop site

I have a site that stores an index.php for desktop computers and a mobile.php for mobile devices. Both files are in the same directory (say /var/www). As default the user accesses index.php and if ...
2
votes
1answer
110 views

.htaccess — Trailing slash and characters after file extension

I've got some weird usability warnings popping up in my search console for pages which don't actually exist on my site. It looks like someone is creating 100's of malformed links to my pages. Here's ...
1
vote
1answer
45 views

Clean URL's within subdirectories

I have a website with the following structure index.php contact.php about.html forum(dir) - index.php - thread.php What i want my htaccess to do Remove .php & .html extension, eg: when you ...
1
vote
0answers
34 views

How to fix duplicate title tags canonical for / vs index.html

I am confused, after scanning by an online SEO tool, it says: error duplicate title tags canonical; https://cleanmypc.co.uk and https://cleanmypc.co.uk/index.html I have in my .htaccess file ...
1
vote
1answer
155 views

Htaccess won't work with ajax/php

Sending ajax request by jquery doesn't working with htaccess. Works without htaccess. product_configurator.php -> fetch_data_p.php $.ajax({ url:"fetch_data_p.php", ...
1
vote
1answer
17 views

Htaccess Using RewriteMap with a text file

I can't use link with * Example - http://localhost/photo_gallery/public/show_c.html/color-1* The requested URL was not found on this server. The others work's color-3, wood, etc. generated map - map....
1
vote
1answer
40 views

.htaccess url rewrite remove 2 id

Is it possible to delete 2 parameters ID of the url & just show the number. Currently i have url like this: http://localhost/photo_gallery/public/product_configurator.html?prometheus_id=10082&...
2
votes
1answer
35 views

How can I redirect my URL to rearrange the order of subdirectories in .htaccess?

My current URL is example.com/example/{dynamic_id}/{dynamic_name}/static/1.html I want to redirect it to this, example.com/{dynamic_name}/example/{dynamic_id}/static/1.html I tried but failed.
1
vote
1answer
70 views

Url changing with htaccess

I have a web presentation with some typical url adresses. Now I need to add a rewriterule for a different languages, examples: domain/club -> do not change domain/club/path -> do not change ...
2
votes
1answer
77 views

Will deleting and re-upload my new site site help Google index it and resolve duplicate URLs that are now fixed?

I uploaded a new site with a domain name https://example.com (actually the domain consists of 3 words concatenated together). If i do a google search for those three words in Google, the site does ...
1
vote
1answer
63 views

Blocking bad bots based on useragent in apache conf

I am proposing blocking bad bots using the following code in /etc/sites-enabled/site.conf and I have a few questions. RewriteEngine On RewriteCond %{HTTP_USER_AGENT} useragent1|useragent2|useragent3 [...
4
votes
1answer
70 views

htaccess force https not working if there is not an URI

I've never worked with Apache, so I'm a completely newbie. I have a multihosting account on a provider website, where 3 domain are used. I want to force https connection on a domain, let's say example....
2
votes
1answer
90 views

How to Redirect URL with special Characters?

I try to redirect a special URL in .htaccess, as below: Redirect 301 /aor/%e2%80%9d https://www.example.com/outlook-repair/ But this seems does not work. I try to add quotes, as follows: Redirect 301 ...
2
votes
2answers
207 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
47 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 ...
1
vote
1answer
54 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
115 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
69 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
47 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
237 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
56 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
33 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
38 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
44 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
221 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
2 3 4 5
31