Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
1
vote
3answers
2k 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....
5
votes
2answers
2k 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
760 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
2k 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
4k 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
1k 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
526 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
832 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....
2
votes
1answer
111 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
256 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
596 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
3k 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
348 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 ...
7
votes
2answers
2k 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 ...
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 ...
0
votes
1answer
61 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
807 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
670 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: # ...
2
votes
0answers
540 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
365 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 ...
3
votes
3answers
340 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
269 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
547 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
163 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
577 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
120 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
635 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
527 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
3k 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
1answer
88 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
1k 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
703 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 ...
1
vote
3answers
2k 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 HTTPS ...
2
votes
1answer
309 views

Simple .htaccess language question (redirection)

I do not know the language of .htaccess, thus the newbie question. I have this code: RewriteEngine On RewriteCond %{QUERY_STRING} ^m=1$ RewriteRule (.*) /$1? [R=301,L] It redirects any urls that ...
2
votes
1answer
673 views

.htaccess redirect strip old system content from end of URL

Looking to redirect all URLs which look similar to this: https://www.example.com/discussion/topix/random-page-title.133760/posts/1255466/rate?rating=13&_Token=78139%2C1464617730%...
2
votes
2answers
12k views

How to remove subdirectory folders from the url using htaccess

I am trying to remove the sub-folders from my site URL. Below is the structure of my folders. I am not sure where to place my .htaccess file and what to have written in it: mysiteroot ...
1
vote
1answer
1k views

“Content Encoding Error” when refreshing a page with a tracking parameter

Our email marketing system tracks clicks by appending a unique string after links within the email i.e. www.example.com/buy-now?tracking1 & www.example.com/buy-now?tracking2 etc. The problem is: ...
2
votes
1answer
4k views

301 redirect all child pages to parent directory using .htaccess

I need to 301 redirect all child pages of a specific parent directory on my website. i.e. redirect www.example/com/parent/child and www.example.com/parent/another-child etc. to www.example.com/...
1
vote
1answer
59 views

.htaccess redirect for one file

Somehow an erroneous URL of mine got indexed by Google. Which is: www.example.com/index.php/ All I want to do is redirect it to the same URL without the / at the end. I have the below that seems to ...
4
votes
2answers
70 views

.htacess - Remove .html from the homepage but not from folders within within that website

I'm trying to remove the .html from my landing page, an example would be instead of domain.com/contact.html it would be domain.com/contact while at the same time keeping the .html for all the folders ...
4
votes
1answer
149 views

Solving corruption in a .htaccess flle

I received a call from Go Daddy indicating that my site had been hacked and the .htaccess file is now an issue. The code in my .htaccess file is as follows RewriteEngine On RewriteCond %{...
1
vote
1answer
3k views

How do I prevent a rewrite rule from executing for just one subdomain?

In the root level .htaccess I have added a condition to rewrite HTTP requests as HTTPS: RewriteEngine On RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} This applies to ...
3
votes
1answer
289 views

Redirect 301 for Apache Sub directory and query string combination

I am getting 404 errors in Google Search Console for URLs like the following: http://www.example.com/newsite12121212121212/eg/st_tour/perma/ http://www.example.com/newsite12121212121212/eg/...
4
votes
6answers
247 views

Should my users' profile page URL be /user/bob or just /bob?

Currently, the URL to a user's page is this: website.com/user/bob But I'm considering changing this to be: website.com/bob Without the /user/ part. It comes across as much cleaner and easier to ...
4
votes
1answer
538 views

Redirect 301 directive for Apache has no effect for URL with query string

I have this old link http://www.example.com/?page_id=617/ that I want to redirect to the home page. I've tried to implement this redirect with: Redirect 301 /?page_id=617/ https://www.example.com/ ...
5
votes
3answers
652 views

Temporarily redirect WordPress url with query string from root directory to new url

This post seems to have my answer: How can I redirect old WordPress URL (with a query string) to new URL using .htaccess? However, this does not seem to play nicely with WordPress' previous rewrite ...
2
votes
1answer
46 views

I couldn't create .htaccess redirect

From /etiket/(any page) to /konu/(any page). How can I do it? In .htaccess file. I searched and applied it but couldn't. # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase ...
2
votes
1answer
139 views

Enabling Multiviews is how you make a web server able to open links with missing extensions?

I'm in the process of switching web hosts. My old host was of the beginner-friendly 'kid gloves' variety. I had less control, but it took care of a lot of things behind the scenes. My new web host ...
2
votes
2answers
59 views

SEO executive .htaccess file knowledge

Should SEO executive in a company have knowledge of .htaccess file to make changes in that file or it is the task of developer in the company to make even small changes? In short what I am asking is ...
1
vote
1answer
48 views

If there is no page, redirecting to the other site

I moved my site and I want to use the old site. The best way to use both is to show the current pages, if there is no page, redirect to the same address on the new site. Can I do this only from the ....

1
5 6
7
8 9
30