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

2
votes
1answer
402 views

Return 410 Gone status for all .html files except a single one?

I bet there's at least one trivial solution to this problem, but I've yet to figure any of them out. In a nutshell, what I'm trying to achieve is, informing the search engines that there are no more ....
4
votes
1answer
578 views

How to add force https to htaccess file RewriteRule with _route_=$1

I inherited support for an Opencart 1.5 site which needs to have SSL enabled. I've edited the config.php files in / and admin/ and adding https:// to the URL is working in the browser and links are ...
3
votes
1answer
36 views

htaccess redirect to another website while cutting a string from address

I'm trying to make a redirect with htaccess. Let's say that I have two websites: www.oldsite.example www.newsite.example What I want to do is redirect old to new with random_file.html renamed to /...
1
vote
1answer
560 views

Forcing trailing slash at end of “fake” folders

The working codes that I've found here most put a slash in everything. I just need force trailing slash in these "fake dirs" (that are part of my rewriting scheme (only directories)) and keep ...
3
votes
1answer
67 views

Redirecting to subdomain, impact on SEO?

I've been working on a web platform project for a client, and we are nearing completion. Basically, the platform is a small social network for a specific group of people. Part of the specification is ...
1
vote
1answer
100 views

How does Google crawl dynamic URLs?

I'm trying to crawl my website using the google webmaster tools, but I'm curious as to if I've setup my parameters correctly. On my website I have different pages that's content is relative to a url ...
2
votes
1answer
407 views

Deny access to one of two sites using the same .htaccess

I need to set up my .htaccess file to deny access to the site if they are accessing the staging.example.com. I have a Magento 2 store and have set up deployment using Capistrano, which will be ...
4
votes
1answer
73 views

How to redirect from https://hi@example.com/x, to just https://example.com/x (htaccess)?

I have a weird problem where for some reason search engines see that I have duplicate URLs, like https://hi@example.com/x and https://example.com/x I'd like the first (i.e. with hi@) to 301 redirect ...
1
vote
2answers
2k views

Forcing https causes all folders to redirect

I have quite a large site that consists of some regular web pages in the root and a lot of Joomla sites in folders. So it looks a little like this: - index.php (root) - about.php (root) - product....
3
votes
1answer
30 views

Redirect IPSuite “?/topic/” URLs to “?thread/” for Woltlab

I moved from IPSuite forums system to Woltlab burning board forum system. What happen next was that my old links that start with: example.com/index.php?/topic/ Now start with: example.com/forum/...
1
vote
0answers
251 views

How to use htacess to Stop Spam hits originating from specific domains? [closed]

I am getting loads of spam/junk hits on my sites, they result in thousands of hits per day which is crippling my server resulting very poor performance on adsense revenue. Although I am blocking them ...
6
votes
1answer
605 views

Rewrite wildcard subdomains in .htaccess to corresponding folders on the main domain while preserving the subdomain

I'm trying to rewrite a subdomain to a folder/file like this: name.example.com -> example.com/profile/name foo.example.com -> example.com/profile/foo xyzzy.example.com -> example.com/profile/xyzzy ...
3
votes
1answer
881 views

How can I make a specific series of URLS have “410” Gone status?

Server was hacked and my .htaccess file was changed to wildcard redirect (spam). I am seeing a lot of requests like those below even after I've cleaned up my server: example.com/cobwebbing-...
1
vote
3answers
1k views

how to properly cache a static website .htaccess

The problem i noticed with my static website. Is that the css is not renewing itself once I updated the website code at areas (Adding new pictues, text, colours). I checked immediately once i updated....
4
votes
2answers
803 views

How could I forcibly output the default 403-forbidden error page when http://example.com/not_found is requested?

This is my first question on StackExchange so bear with me, here is a brief breakdown of my current setup: Two different domains, two different TLDs (.dk and .de) on the same hosting plan for the ...
2
votes
0answers
554 views

Apache basic authentication without instant prompt for credentials

I'm looking for away to eliminate the intrusive instant prompt for credentials when basic authentication is used and instead serve a nice page that tells the user where he is and what credentials to ...
0
votes
2answers
824 views

How can I block who.is and archive.org from getting information of my website with htaccess?

who.is is a service that gives people whois information of websites and archive.org automatically saves people's website. How can I block them using htaccess from getting access with my website?
2
votes
1answer
2k views

“Invalid command 'php_value'” in .htaccess for WordPress site after switching hosts

I moved my site which was on 00webhost to a new host. I set everything up but a 500 internal error shows up. The error log reports the following: [Sun Feb 11 23:43:59.139864 2018] [core:alert] [...
1
vote
2answers
546 views

how to use .htaccess to redirect http to https for 3 domains cPanel

I have 3 domains. 2 are Addon domains, 1 primary on my cPanel. I do not know if this is possible but from .htaccess how can I set this up: example1.com (Primary) example2.com example3.com This is ...
4
votes
3answers
321 views

Rewrite to SEO friendly URLs for language negotiation with type-map files on plain html files using .htaccess

When visiting the website www.example.com/ the visitor should be redirected to the correct language version, e.g. www.example.com/en for english and www.example.com/es for spanish. My current ...
3
votes
1answer
600 views

Full domain .htaccess 301 keeping same paths, but also redirect some URLs to different paths

I believe the following code will redirect my old domain to my new domain keeping the same URL paths. RewriteEngine on RewriteCond %{HTTP_HOST} !^www\.newdomain\.co.uk RewriteRule (.*) https://www....
3
votes
1answer
72 views

How to 301 redirect back to a pretty link without creating an infinite loop in .htaccess

I am doing a rewrite from .htaccess file to redirect pretty links to original URLs: RewriteRule ^users/?$ /?status=users [NC,L,QSA] which redirects my SEO/pretty link: example.com/users to the ...
3
votes
1answer
203 views

How do I do an htaccess rewrite on an internal URL without Google crawl giving me a soft 404 error?

Here is my issue. I have a rewrite rule in my htaccess like this: RewriteRule ^(news|review|feature|editorial|podcast)/([0-9]+)/(.*)$ /article.php?id=$2 [L] Basically what it does is take in a URL ...
3
votes
1answer
225 views

.htaccess repeatedly asks for username/password

I'm trying to add password protection to my personal website using .htpasswd and .htaccess. When I enter the username and password, I get asked again and again. How do I resolve this? .htpasswd st:((...
1
vote
1answer
787 views

How to pass a match from the regex in a condition to the rule in .htaccess

I have an .htaccess file with rules like this: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} /apples/* RewriteRule . /page/faqs.php?cat=apples&...
1
vote
1answer
204 views

Should I be returning a 301 or 403 to a bad referrer in my .htaccess?

Getting several amounts of bad requests from a particular URL such as site.foo and I would like to redirect all these requests to a dedicated page. The .htaccess code I've researched and implementing ...
6
votes
2answers
772 views

HSTS Preload section on .htaccess

Recently having moved a site to SSL, I looked into enforcing HSTS for eventual preload. The syntax is approved and the Chrome List allows it to be OK. However, not being a coder at all, a slight ...
-1
votes
0answers
680 views

Remove query string from 301 redirect [duplicate]

we would like to 301 redirect all URL query strings to the corresponding URL path without query string. Our URL look like this: https://www.hunter.games/cs/game/detail/geolokacni-hra-praha-prokleti-...
0
votes
0answers
49 views

Cannot add to cart, logout, or write to .htaccess after changing site address WordPress

I recently just changed my Site Address from the admin panel on my WordPress website. After doing so, I got an error from my caching plugin WP Rocket saying it couldn't complete configuration because ...
4
votes
1answer
909 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 ...
0
votes
1answer
52 views

htaccess rewrite url

is it possible to create a 301 redirect for the following URL string: Original URL: http://www.example.com/old/old-directory/blog-post-1.html Desired destination URL: http://www.example.com/new/new-...
3
votes
1answer
492 views

.htaccess with Unicode and normal English

I have the following .htaccess code: RewriteRule ^Indian-Patriot-Name/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([^\x00-\x7F]+).*?$ indianpatriot.php?id=$1&lid=$2&name=$3 [B,L,QSA] Which allows me to ...
3
votes
1answer
401 views

XenForo SEO Friendly URL returns 404 on forum page

I have my .htaccess file in the base directory of the installation of XenForo. When I enable SEO Friendly URLs, it returns error 404 only on the forums and members pages. htaccess file: # ...
0
votes
0answers
256 views

Compressing third party resources with Gzip on .htaccess [duplicate]

I am trying to optimise a website according to PageSpeed Insights, and in the guidelines it mentions compressing third party resources with Gzip. I already added this code in .htaccess: # BEGIN ...
2
votes
0answers
386 views

How to use .htaccess rewrite rules to remove .php and folders from URLs?

I'm trying to simplify the URLs using rewrite condtions and rules on my local WAMP website. For example I would like to have /ProjetSyntheseFAC/mammiferes instead of /ProjetSyntheseFAC/pages/animaux/...
4
votes
1answer
225 views

addon domains keeps adding primary domain in URL

I took new vps plan from inmotionhosting.com and moved my host from previous hosting company. I have several cpanel accounts in the whm, imported them all using the migration tool from server to ...
4
votes
3answers
292 views

How to use a RewriteRule and Redirect 301 at the same time?

I have my Url with multiple parameters: mydomain.com/?vote.php?ranking=parameter1&lang=parameter2&period=parameter3&provider=parameter4 but I would like to change my urls to SEO friendly....
3
votes
0answers
268 views

.htaccess permanent redirection with condition [closed]

I want to redirect ONLY users from website1 pages to website2 homepage. The google bot and other crawlers must indexing and do not know about redirection. Can you help me? I know how to place the ...
1
vote
1answer
341 views

404 errors turning into 500 errors through internal redirects

Today I checked my Apache error.log and I found many: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if ...
0
votes
1answer
38 views

Block company domain from apache website how?

so I am running a site on apache. I want to block all visitors from domain *.xyz.com I tried adding the following in .htaccess file: <Files *> order allow,deny allow from all deny from .*...
2
votes
1answer
316 views

Use .htaccess to rewrite any subdomain to the corresponding subdir without revealing the subdir

I have a little problem with my .htaccess. For example, if I go to test.example.com, it's in folder /sub/test. But it shows test.example.com/sub/test. How can I hide the path after .com? Or is there ...
2
votes
2answers
81 views

.htaccess RewriteRule leading to unexpected page

I'm trying to do a simple invisible redirection with .htaccess which almost work. I'd like my main domain name example.com to access the content of the folder example.com/V8/ but keeping only the ...
2
votes
0answers
438 views

How do I redirect a URL with a question mark? [closed]

The ? is not part of a query but used as if it were an actual question. Here's an example: /how-did-penicillin-change-the-world?.html What's the best way to redirect that URL to something like /news....
4
votes
2answers
257 views

Using 301 redirects to change domain and maintain SEO

I’m setting up a Wordpress website with a new domain name to replace my client’s current website. I’d like to redirect the old domain to the new domain in a way that will maintain the search engine ...
2
votes
1answer
2k views

How do I configure gzip to work on External Resources

In order to do this I put code to .htaccess: <ifModule mod_gzip.c> mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-...
0
votes
0answers
19 views

How to set up a multilanguage website with different TLDs? [duplicate]

I own three different domains: mysite.com mysite.co.uk mysite.de and want to publish my content in english and german. I would like to know how to do this concerning SEO. My first thought was to ...
0
votes
1answer
44 views

Replace all url start with “ m.” to without “.m” ( m.example.com/index.html To example.com/index.html)

Our previous website has one sub directory called "mobile". So in the main pages we write code if it is screen size less than 640px then go to mobile/ folder . <link href="http://mobile.example....
1
vote
1answer
665 views

Website redirects to httpss (not https) in Safari and IE but not Chrome

I have made a redirect rule in my .htaccess file for https://pg-flowsolutions.com that specifies that if someone enters an invalid path (for instance https://pg-flowsolutions.com/blablabla) the ...
2
votes
1answer
448 views

htaccess empty referer deny “google bot”

I put this rule into htaccess file to deny empty referers which is returning 403 SetEnvIfNoCase Referer "^$" bad_user Deny from env=bad_user I can see the log, it's denying also Googlebot which ...
2
votes
3answers
1k views

HTTP to HTTPS redirect: How not to create an infinite loop

I have a WordPress install on a subdomain: https://blog.example.com To enforce SSL I have the following redirects in my .htaccess: <IfModule mod_rewrite.c> RewriteEngine On # BEGIN FORCE ...