Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
2
votes
0answers
586 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
433 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
62 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
590 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 ...
2
votes
1answer
281 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
590 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
8k 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
964 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
3k 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
55 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
68 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
93 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
2k 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
227 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
230 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
508 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
603 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
111 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
58 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
47 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
vote
1answer
119 views

setting rewrite rules in httpd.config file at host server

I am a new webmaster. I plan to host my website on a dedicated server. The website has three TLD: .com, .ma and .fr. I have a couple of rewrite directives in my .htaccess file that force the URL ...
2
votes
1answer
309 views

410 response code in subdirectory

I have an htaccess file in one of my subdirectories. I'm trying to throw a 410 response code for .doc and .pdf files in my uploads directory for my multisite installation. So my .htaccess file is in ...
2
votes
1answer
120 views

Internal redirection: Serve “/site” as “/” and “/sub/blog” as “/blog”

I have a website with a shared hoster. There are a few things that I have there, like main site, Piwik, a blog and other standalone things. Right now I have the following structure: ~/subs/www gets ...
2
votes
1answer
26 views

How do I integrate rewrite rules to forbid requests referred from a domain with existing rewrite rules in .htaccess?

I have read about how to do this using the following: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_REFERER} ^https?://([^.]+\.)*website\.com [NC] RewriteRule .* -...
2
votes
1answer
444 views

My website keeps redirect to the “index.php” account on Instagram app

My htaccess code allows example.com/username redirect to any username on Instagram app. But when I open example.com it redirects to an Instagram account called index.php. How can I fix it? Here is my ...
2
votes
1answer
773 views

How can I redirect example.com/username to Instagram app directly open from deep link?

I'm trying to redirect from example.com/username​ to Instagram deep link instagram://user?username=anyusername Here is my htaccess code RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^(www\...
2
votes
1answer
322 views

.htaccess (AddIcon AddDescription AddAlt) not working on directory .URL files

I have recently learned how to use my .htaccess file and a script to rewrite .URL shortcuts into functional links in a directory listing: Make .URL shortcuts into functional links within a Directory ...
2
votes
1answer
193 views

When mass redirecting URLs from the old site, can I redirect everything to the home page of the new site for SEO?

I need to redirect thousands of URLs to my new site (its the same domain, but now is on Wordpress), I don't want to lose all the SEO from the old posts, but I don't know how to redirect each old link ...
2
votes
0answers
698 views

Redirecting domains, sub domains and single pages on Siteground

I'm having serious issues with Siteground to get my redirects working. They did work on another hoster so it is possible. However, that server configuration was very different so I cannot copy what we ...
2
votes
0answers
91 views

.htaccess to show a page from the main site on another domain

I have 2 x domain names https://www.example.com - This is my main site. http://www.example-liverpool.com This is my Liverpool sub website example.com/liverpool I've presently got URL forwarding ...
2
votes
2answers
913 views

Redirect to WWW with HTTPS optimization

I want to redirect all my website pages to https and www. In order to do that I'm using the rules below and it's working fine. # Rewrite to WWW with HTTPS RewriteCond %{HTTPS} off # First rewrite to ...
3
votes
1answer
1k views

htaccess 301 to redirect .com to .co.uk, http to https and non-www to www subdomain

I have example.co.uk and example.com domain names. The main website is example.co.uk. I have an SSL certificate on the domain example.co.uk. I want the .htaccess file to 301 redirect everything ...
2
votes
0answers
432 views

Edit .htaccess so that homepage of Laravel site mirrors homepage blog

I have a Laravel site at example.com and a WordPress site at blog.example.com. Everything works well except that I'd love to have the root (index page) of example.com show (but not redirect to) the ...
2
votes
1answer
502 views

Redirect subdomain to their folders without double slash and such that parameters get sent through login

I have a wildcard DNS setup on my server, something like .example.com. In my root folder there are some sites, so what I need is to have something like this: test.example.com should use test directory ...
0
votes
2answers
1k views

Apache .htaccess: Is it possible to write an if condition for a cookie value check?

I want to write an if condition in an .htaccess file to check whether a cookie value is set. Example code: <If "%{HTTP_COOKIE} == 'cookiename and value'"> ... </If>
0
votes
1answer
365 views

.htaccess redirect based HTTP_REFERER [closed]

Our webpage was redesigned and moved to a web CMS platform. This means some of our blog posts shared via Twitter just link to a 404 page. I am wondering if it is possible using .htaccess or something ...
1
vote
1answer
1k views

.htaccess doesn't redirect my pages from HTTP to HTTPS

It seems like .htaccess doesn't redirect my pages from http to https. My domain is redirected to https but not my pages… Can it be a bad configuration from my web host? Here is what I have done ...
1
vote
1answer
461 views

.htaccess to force SSL and also rewrite such that the content is served from a sub-folder

The issue is how to do two things: force SSL on all requests, and redirect the domain to the public_html/somefolder - where the site/domain content lives. The recommendation from the hosting place (...
1
vote
1answer
142 views

htaccess force ssl

I need to force all traffic for all pages on example.com to https://www.example.com . After much googles, and hosting site help docs, the consensus (and what my hosting - BlueHost - docs say to do) ...
1
vote
2answers
40 views

Rename translated documents into ending language initials

I am building a web app and trying to add two languages to the website. So I will make the same documents ending in -gr. Some examples of the files look like this: English Language paths: www....
5
votes
2answers
849 views

Make .URL shortcuts into functional links within a Directory Listing

I use a lot of directory listing on my website and want to make .URL shortcut files into functional links. These .URL shortcuts were made by dragging the websites' icons from my Firefox URL bar to my ...
2
votes
1answer
2k views

Url rewrite not work in wamp localhost

I am developing a PHP web application. I have pages, posts, categories, product and etc. Here is my .htaccess file to create SEO friendly URL: Options -Indexes RewriteEngine on RewriteRule ^Page/(.*)...
2
votes
2answers
572 views

How to tell google that domain no longer exists but still make redirects from that domain

I have two domains: example.com and dev.example.net. example.com is the active one and dev.example.net should be invisible to Google. dev.example.net has 301 redirects to example.com and it has its ...
3
votes
1answer
1k views

URL-path with encoded question mark results in incorrect redirect when copied to target URL

I have a simple RewriteRule, appending a string to some URLs: RewriteRule ^labels/([^/]+)/?$ /labels/$1/releases/ [R=301,L,NC] The links are database driven, and this is working very well. Well, ...
5
votes
2answers
8k views

Redirect from URL with parameters to SEO friendly URL in .htaccess

I have category page with this structure example.com/Category.php?Category_Id=10&Category_Title=some-text i want to write htaccess rules to redirect from example.com/Category.php?Category_Id=...
2
votes
1answer
3k views

htaccess / FilesMatch / DirectoryMatch allow .jpg .html and directories

Navigation in my site is like this: www.example.com/pictures/cars/ etc I am trying to allow only .html and .jpg in these folders, but I also need the directory to be accessible Order allow,deny ...