Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
1
vote
2answers
75 views

Issues with redirect rules to redirect all URLs except one page

I need to add following Apache redirect rules to .htaccess: http://www.example.com to be redirected to http://www.onemoreexample.com but http://www.example.com/support should not be redirected. To ...
1
vote
1answer
52 views

Can certain pages load without “.html” extension, instead of whole site?

I set up my website so that all pages load without the .html extension, using the following code in the .htaccess file: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ...
1
vote
1answer
37 views

Researching .htaccess Syntax

In my template .htaccess file I have been copying and pasteing alot of rules and researching .htaccess for around 2 weeks in an attempt to try and better understand the syntax, different modules & ...
1
vote
2answers
1k views

Where to place 301 redirects in the .htaccess file on a WordPress site

I edited my .htaccess file earlier to redirect from www version to non-www, and it is working correctly. However, now I have some page redirects I need to do. I am looking at the .htaccess file, and I ...
1
vote
1answer
26 views

Using htaccess to redirect 301 for domain change

I am currently moving a domain from one to the other, this is not an HTTPS move but rather a move from exampleone.co.uk to exampletwo.co.uk. I am using this code: <IfModule mod_rewrite.c> ...
14
votes
2answers
76k views

Font blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin'

we are experiencing this error in Google Chrome. We thought everything was set-up correct. But maybe not? Font from origin http://skin.cdn.com has been blocked from loading by Cross-Origin ...
2
votes
1answer
21 views

Redirect root to subdirectory of current year if this exists, otherwise to a previous year that does exist

This kind of htaccess code is a little complex for me as I'm just beginning to understand redirects with htaccess. Could someone help me with this? Thanks in advanced.
1
vote
1answer
36 views

rel canonical for http and https

For some reason I need to keep both http and https versions of my site. I am using wordpress. Can I add a rel=canonical for https version through the .htaccess? What is the easiest way to avoid ...
1
vote
1answer
43 views

How to redirect all requests to HTTPS with SEO friendly URL using Apache?

First of all, I would like to leave remove www and redirect all request to HTTPS like this: RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} ^www\. [NC] RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$...
2
votes
1answer
546 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%...
1
vote
0answers
45 views

Considering changing URL structure from example.com/page?id=1 to example.com/1/keywords but wondering what SEO impact is

Currently our website has a variety of community generated content that is under the URL structure of example.com/page?id=1. Some of these pages rank quite well on Google due to a combination of ...
0
votes
1answer
58 views

How can I resolve htaccess causing social media bots to see 404 response even though the page displays correctly?

I use the below htaccess code which appears to function correctly to rewrite URLS, however when a page is shared to social networks or scanned by bots like AHREFs, they all return 404 yet the pages at ...
2
votes
1answer
952 views

Restricting post method and authentication to specifc URL paths in Apache .htaccess

I shall start with an example. I want to restrict to POST requests only for http://path/to/logical/abc.xml and restrict to GET only for http://path/to/logical/def.xml. How do I put constraints like ...
1
vote
1answer
32 views

Rewrite rule to give 410 Gone for a specific URL doesn't work

I'm French. A week ago, my website was hacked with the old version (http). The hack created 404 spams and I want to ensure they have "410 Gone" status. My problem on the site is: https://www.example....
3
votes
2answers
8k views

Unwanted redirect from a domain to my site

An external person from my client company registered a domain and redirected to my client URL. For instance, if you type unwanteddomain.com it redirects to myclientdomain.com. Is there any way to ...
1
vote
1answer
20 views

How to Redirect all subdirectory pages to another?

Due to duplicate content issue, I want to redirect all pages of /articles/* to newly created sub directory /article/*. How do I redirect all pages of /articles to /article using .htaccess file?
0
votes
1answer
1k views

Using Apache's rewrite module to set up local host names for development

I have several websites on my development machine under Apache's htdocs folder. Apache Directory root is htdocs, but I want to be able to access each different site there by individual domain names. ...
2
votes
1answer
27 views

Trying to create 1-1 redirects, exclude certain directories/files, and then redirect any other traffic to new website

I'm stumped on how to achieve this. The 1-1 redirects work fine as well as the global redirect to send anything to the new page that isn't contained in the code. But when trying to exclude one (or ...
5
votes
2answers
24k views

How to disable gzip compression using htaccess

I want to disable gzip compression in my site using htaccess. I have the code below in htaccess: php_flag zlib.output_compression off But it is not working.
1
vote
0answers
23 views

invoke a URL Perl script silently, without changing URL visible to client

I've been fighting the Google canonical page algorithm bug for 2+ months. Following various forum advice and suggestions haven't solved it yet, although for sure they've made our website better. One ...
5
votes
4answers
7k views

using .htaccess to redirect .asp to .php?

Ahoy all! I've been racking my brain with this one. I basically just converted all of my pages from ASP code to PHP code. Kept the same filenames. So, here is the htaccess code I have so far, but ...
1
vote
1answer
19 views

How to ignore/redirect all URLs matching a certain string

I am using the WordPress plugin, Timely All-in-One events calendar. Unfortunately it is creating a plethora of duplicate URLs which end in strings like https://www.example.com/events/action~agenda/...
0
votes
0answers
20 views

How do I locate files that appear to be located before the webroot?

I'm now administering a site for a small professional organisation. The website is hosted with GoDaddy. Most of the links don't work as the site was migrated back from https to http. All of this work ...
1
vote
1answer
65 views

Could someone explain what these .htaccess rules and “.well-known” conditions are for?

I am confused about both the purpose of .well-known exceptions and so many conditions. Is this just something temporarily put in place by the host or is it best practice to keep it in place? Why are ...
2
votes
3answers
96 views

htaccess redirect all traffic to secure non www version of page

I'm having trouble with my .htaccess redirects. I need to forward all URLs to the non www version of the URL using HTTPS and also forward any non secure URLs to HTTPS too. In both cases I need to ...
2
votes
1answer
2k views

How to set expire date for PageSpeed Insights google in Laravel?

I create .htaccess in root project and add this code for set expire date for css and js. My server is Ubuntu 16.04 But this code not work for my website. This code in htaccess: <IfModule ...
1
vote
2answers
42 views

htaccess url rewriting 2 get values

I am using PHP 7.2 URL Rewrite Rules. i am making 2 links first link is "category.php?inventory_id=" and second links "show-subcategories.php?cat_id" but the result is always the first link is working ...
2
votes
1answer
37 views

Do search engines crawl links with query strings?

If I were to have a url like https://example.com/books, that contained several links to urls such as: https://example.com/books?id=foo https://example.com/books?id=bar https://example.com/books?id=...
1
vote
1answer
34 views

.htaccess rule to redirect entire site except for a couple pages is not working

I've been pulling my hair out for a couple of days over an .htaccess issue. I have a list of redirects which are all being done in this format: Redirect 301 /my-page/ https://www.example.com/my-page/ ...
4
votes
3answers
900 views

301 Redirects what does ([a-z]+)-(.*) and ([0-9]+)-(.*) mean

I just checked an .htaccess file with some custom redirects. There are two redirects I don't fully understand: RedirectMatch 301 ^/news/([0-9]+)-(.*) /blog RedirectMatch 301 ^/news/([a-z]+)-(.*)/$ /...
2
votes
0answers
37 views

Is it safe to do a htaccess rewrite for mobile traffic to amp pages?

I have a requirement to use the same URL for both desktop and mobile devices. On mobile, I want to serve amp HTML while on the desktop I want to render normal HTML. In such case is it safe (from SEO ...
1
vote
1answer
37 views

Redirected too many times when I try to force https for all URLs

I want to redirect all website urls to https. I used the code below to do so. My website is built up using simple PHP. I don't use any opensource framework or CMS. RewriteEngine On RewriteCond %{...
0
votes
1answer
27 views

How to remove subdirectory and index.php from URL with htaccess?

I've got an apache website stored on the server at /var/www/website/ and it's the only one on that server. I'd like to adjust the URL accordingly. How can I make an .htaccess rule that would do this? ...
3
votes
1answer
59 views

Redirect domain name to a specific page

I have theses domain names installed: Main domain name: www.example.com Others domains: www.example.org www.example.fr www.animals.example I first made a rule on my .htaccess to redirect all ...
1
vote
1answer
83 views

How to bulk redirect in htaccess from old site with parameters

I'm currently updating an old website, but I don't know much about htaccess redirects. I made a script to get all the pages of the website and here are some examples: For pages: Redirect 301 /index....
4
votes
1answer
7k views

Apache .htaccess mod_rewrite: use of [NC]

I see tons of .htaccess examples containing the [NC] flag (NoCase = case-insensitive) For example the famous h5bp page uses the [NC] flag a lot: https://github.com/h5bp/server-configs-apache/blob/...
4
votes
1answer
60 views

Does having a lot of 301 redirects noticably impact performance?

I just moved my website to Wordpress from another service. Unfortunately, this means that although I was able to import all of my previous content to Wordpress, the post permalinks are now entirely ...
1
vote
1answer
17 views

regex on htaccess not working as expected

I have this rule on my .htaccess that doesn't work as I would expect: RewriteRule ^/rg$ /download/file_1.pdf [NC,L] I would like to redirect all the requests from www.example.com/rg to download this ...
1
vote
1answer
39 views

Website not working when adding .htaccess

I have my website hosted on a CentOS server. When I add the .htaccess file it stops working showing "Internal Server Error". On a side note: when I remove the .htaccess file the website works only ...
2
votes
3answers
7k views

.htaccess mod_rewrite 500 internal server error due to too many internal redirects from LimitInternalRecursion

Whenever I place my .htaccess file in my web directory I receive a 500 internal server error and within the error.log file specifying: [Sat Jan 21 13:46:07 2012] [error] [client xx.xx.xxx.xx] Request ...
2
votes
1answer
454 views

Internal Server Error 500 when specifying AddHandler and FCGIWrapper for PHP in .htaccess

For years, I have been using the following .htaccess for PHP to execute within HTML on Apache at GoDaddy: AddHandler fcgid-script .html FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .html A few days ...
2
votes
1answer
35 views

Redirecting using rewrite rules from international top level domains to a language subdirectory doesn't change the domain name

I want to change from TLDs to TLD and language code. Right now we have 4 TLDs for our webpage: example.de example.com example.nl example.fr Now I want to change our settings of our CMS (Contao) to ...
1
vote
0answers
47 views

Password protect a website only if it is the dev site [closed]

I am trying to password protect a website only if it is the dev site using .htaccess and .htpasswd I am using Apache 2.4.29 on Ubuntu 18.04 Here is what I have in the .htaccess file <If "%{...
1
vote
2answers
60 views

What does ^(.*) mean in a rewrite rule, is there a simpler alternative?

I have just copy and pasted a rewrite rule for a redirect from some website. It contains: ^(.*) I want to know what it means. Why is it so complicated? Can it be simplified? The whole .htaccess ...
3
votes
1answer
87 views

Nginx subdirectory wordpress wp-login redirects to 404 not found

server { location / { try_files $uri $uri/ @extensionless-php; } location /shop { try_files $uri $uri/ /shop/index.php?q=$uri&$args /shop/index.php?q=$uri&$args; ...
5
votes
2answers
7k 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=...
1
vote
2answers
9k views

How to match only part of URL and redirect URL with parameters in .htaccess?

I have a number of links with similar structure: example.com/index.php/path/some-path/some-subpath?parameter=1 Which I want to redirect just to example.com/category/ But I want to match only the ...
0
votes
1answer
7k views

How to leverage browser cache using .htaccess on nginx?

I'm trying to increase the pagespeed of our website ubercore.co. I'm using PageSpeed Insights for Chrome extension to analyze the pagespeed. It has suggested me to "Leverage browser cache". This is ...
2
votes
1answer
53 views

Removing PHP Extension in sub directory

I use the following rewrite rule to remove the .php extension from my page urls: RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] This works great in the root directory of my ...
1
vote
1answer
57 views

Redirect to homepage based on server error code with htaccess

I just took over management of a small HTML website. I discovered the security on the website was almost non-existent because full directory browsing was possible. I have since disabled directory ...