We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
1
vote
1answer
33 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> ...
2
votes
1answer
30 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 ...
1
vote
0answers
42 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 ...
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
116 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 ...
1
vote
2answers
48 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
41 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=...
4
votes
3answers
940 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]+)-(.*)/$ /...
1
vote
1answer
41 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/ ...
2
votes
0answers
61 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
39 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
31 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? ...
1
vote
1answer
21 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 ...
4
votes
1answer
64 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
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 ...
1
vote
1answer
138 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....
2
votes
1answer
73 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
2answers
64 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 ...
2
votes
3answers
181 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 ...
4
votes
1answer
171 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; ...
1
vote
0answers
50 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 "%{...
2
votes
1answer
215 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
117 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 ...
2
votes
1answer
39 views

Order of RewriteRules is affecting the result

This is my current .htaccess: RewriteEngine On RewriteRule ^([\w-]+)/([a-z0-9]+)/([a-z-0-9]+)$ index.php?p=$1&bay=$2&map=$3 [L] RewriteRule ^test/([\w-]+)/(\d+)$ index.php?page=$1&tab=$2 [...
2
votes
1answer
46 views

Apache rewrite to www. unless it is a dev domain

Here is my current rewrite code in my htaccess file: RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] RewriteRule ^ https://www.%1%{...
1
vote
1answer
39 views

How to redirect from blog.example.org to example.com using htaccess

I have tried all means to do a 301 redirect from blog.example.org to https://www.example.com/post using .htaccess but the redirect doesn't seem to be working. I'm using this code below; ...
4
votes
1answer
72 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 ...
0
votes
0answers
26 views

301 Redirection Help for Moving New Domain with New Directory

I have a WordPress website on example.com with 500+ pages. I need to move this site to newsite.com/blog/ I searched this on Google the whole day, but couldn't find how to write 301 for my ...
2
votes
1answer
98 views

How to rewrite specific pages using mod rewrite?

Assuming that my website homepage is https://example.com/test-website/. What I want to do is to add a query string at the end of the homepage URL and on all pages that start with https://example.com/...
0
votes
1answer
77 views

301 Redirect not working as expected

I am in the process of doing a website redesign. We have changed the domain name and hosting server for the new project. Following are the rules that I am using in my htaccess file to perform a 301 ...
1
vote
1answer
84 views

FrontController dosen´t work

i have a example FrontController, its really simple. index.php: if (isset($_GET['page'])) { $requested_page = $_GET['page']; } else { $requested_page = 'home'; } switch($requested_page) { ...
1
vote
2answers
69 views

I have a page with two domains and I want to redirect one of the domains to a specific page via htaccess

I am using the domains ergonomi.example and fysiarbejdsliv.example I want fysiarbejdsliv.example to redirect to https://fysiarbejdsliv.example/dansk-selskab-for-fysioterapi-i-arbejdsliv. I have ...
1
vote
1answer
175 views

Alias subdomain to subfolder (not redirect) with .htaccess (with HTTPS), error ERR_TOO_MANY_REDIRECTS

Well, I'm trying to accomplish this task by using this .htaccess: Options +FollowSymLinks RewriteEngine On # HTTPS (not working: ERR_TOO_MANY_REDIRECTS) # RewriteCond %{HTTPS} off # RewriteRule (.*)...
2
votes
1answer
37 views

Can I use a rewrite rule to send all requests to a single file?

Can I make a single regular expression for all my RewriteRules? I'm rewriting everything to a single file and this this acts like a front-controller. My example: RewriteRule ^de/kontakt/anfahrt$ ...
1
vote
1answer
32 views

redir everything in a folder, but not certain pages - htaccess

How can I edit my .htaccess file to redir everything in a folder, except 3 pages on that same folder Redir everything here: /site/ but exclude /site/page-1.html /site/page-2.html /site/page-3.html ...
0
votes
1answer
60 views

Where to place 301 redirects in my Wordpress htaccess file?

I have about 25 301 redirects in my Wordpress htaccess file, that look like this: Redirect 301 /store/index.html https://www.notesinspanish.com/store-home/ At the moment they are at the bottom of my ...
1
vote
1answer
79 views

Redirecting 404 pages to another active pages in .htaccess

I have one product page indexed on Google but that link does not exist anymore and hits 404 page. What I want to do is to redirect that link in .htaccess to another product page since it ranks very ...
1
vote
1answer
74 views

How to redirect dynamically generated duplicate pages in .htaccess?

I have over 2000 dynamically generated duplicated pages like this: https://www.example.com/subfolder/page1.html and https://www.example.com/subfolder/page1/ What i am trying to do is redirect all /...
2
votes
1answer
107 views

How to form redirect or rewrite where query string contains portion I want to extract to new query string

I've transferred an old custom-made site to Mediawiki and I have many internal and external links to my old pages that I want to redirect to the appropriate wiki page. There are many links to the ...
1
vote
1answer
209 views

.htaccess: Redirect all HTTPS to a subdomain, but EXCLUDE one subdomain folder

In summary: (Notice the "https") I have https://www.example.com All need to be re-directed to https://sub.example.com EXCEPT https://xyz.example.com/api Here is my current .htaccess: ...
1
vote
0answers
46 views

After implementing HTTPS, “require valid-user” in subdirectory no longer asks for password, just gives 401 Not Authorized

I'm not very knowledgeable about server scripting, however I've only just installed SSL certificate for the domain. The main website (hosted by GoDaddy) is now working fine on SSL/TLS and I've ...
1
vote
1answer
87 views

Adding a subdirectory to a URL using .htaccess

I am trying to achieve the following: This URL: www.example.com/wis/9-3/1998/0.general Redirected to this URL: www.example.com/9440/wis/9-3/1998/0.general So I'm trying to add this subdirectory to ...
1
vote
2answers
472 views

Does hotlinking image protection hurt search engines indexing?

Several websites are hotlinking my images, I want to block and prevent hotlinking to my website images. And, I was going to use standard hotlink prevention code in .htaccess: RewriteEngine on ...
0
votes
1answer
135 views

mod rewrite with two parameters and loading folder

I have domain example.com, when someone go to this domain, I need to automatically redirect to example.com/en/ and need /en/ to be a parameter of variable lang. RewriteCond %{REQUEST_FILENAME} !-d ...
2
votes
1answer
554 views

Redirecting all subdirectories of a folder via htaccess [duplicate]

I've searched around and haven't found this specific question asked. I need to redirect all the 'subfolders' of a directory to the parent directory. For example, the parent directory is example.tld/...
1
vote
1answer
59 views

Rewritting .htaccess file to direct to files using a wildcard

Currently my html code points to www.example.com/images/sub/ABCimage.jpg www.example.com/images/sub/XYZimage.jpg Due to a limit on number of files (9999) within the folder , I had to split images ...
2
votes
2answers
87 views

How would Google react if I redirected currently ranking landing pages to the home page?

I have some tag pages on my website which contain specific keywords. They appear in the Google search results for those keywords. Those pages bring in a fair amount of traffic but the bounce rate is ...
3
votes
1answer
38 views

500 error after migrating from Easy Apache 3 to EA4 on Centos6 VPS

I made the mistake of clicking the button in WHM to migrate from Easy Apache 3 to EA4 and now I am receiving a 500 error when I try to visit my site. What have I broken and how can I troubleshoot the ...
3
votes
1answer
83 views

When splitting a folder with tens of thousands of documents into several folders, how can I handle broken links?

I have over 30,000 html files stored in www.example.com/docs, and these files are linked to each other. When it comes to displaying the content of those files on my site, I use the following code: ...