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
214 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
430 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
5k 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
500 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: ...
1
vote
1answer
2k 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
47 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
63 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
83 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
1k 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
138 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
213 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
387 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
465 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
40 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
83 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
57 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
39 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
88 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
225 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
107 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
25 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
314 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
537 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
221 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
173 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
464 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
86 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
732 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
770 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
378 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
341 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
864 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
250 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
772 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
396 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
134 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
38 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....
6
votes
2answers
600 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
1k 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
413 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
917 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, ...
4
votes
2answers
5k 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
2k 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 ...
3
votes
1answer
435 views

“Require valid-user” in “<Files>” section of .htaccess not password protecting directory

I am trying to lock a folder called locked with the encrypted user passwords stored in .htpasswd. This does not work: AuthUserFile /srv/http/.htpasswd AuthType Basic AuthName "Login Required" <...
1
vote
1answer
1k views

Chrome reports a cross-origin font issue despite Access-Control-Allow-Origin header

Chrome: "Font from origin 'https://example.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested ...
5
votes
1answer
362 views

Redirect domain except those users coming from a specific IP address

I've got a Apache web server that serves 2 domains, now in my school one domain is blocked; one isn't (same webpage for the moment). I want that if people connect to my old domain (the one that isn't ...
3
votes
1answer
76 views

How to block my cpanel link for the users who are accessing my website.

I want to block my cpanel link i.e www.example.in/cpanel for the users who are trying to access it, but it should be accessible only for me. Is there anyway to block it. I don't know anything about it....
1
vote
1answer
34 views

If .htaccess is used to block my bot from accessing a particular directory, will I know this?

I'm working on a research project and I have a question. Say I would like to crawl all pages of a given site. In the case that my bot is blocked from accessing a certain portion of the site, I would ...
1
vote
1answer
79 views

Use .htaccess to make pretty URLs that expand abbreviation codes

Yes, I know, there are tons of questions like this, but I can't find one which solves my problem so at cost of receiving downvotes I'm going to ask this again. Even a duplicate link may help me. This ...
3
votes
2answers
342 views

Send “410 Gone” response for URLs that are a “c” or “g” followed by digits

Is there anything i can use in my htaccess to send 410 code to all the links but not some links ? Example: I would like to 410 this urls (List is about 40k links) www.example.com/c1 www.example.com/...