Stack Exchange Network

Stack Exchange network consists of 175 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

-1
votes
0answers
12 views

How to open subdomain without www [on hold]

I have a website and I've redirected that to be opened with www. What I want to do is that I wanna sub domain to be opened without www. What code should I use in htaccess of the subdomain? Any help ...
2
votes
1answer
21 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
22 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
21 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
31 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
28 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; ...
3
votes
1answer
43 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
22 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 ...
1
vote
1answer
34 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
38 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
45 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
51 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
23 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 (.*)...
0
votes
0answers
19 views

Configure apache forwards my site to index.php for root [closed]

Struggling with following issue: CPanel on shared hosting force index to be index.php and fowards any requests to root i.e. '/' to it. I already tried to use htaccess file to override this - without ...
2
votes
1answer
34 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
25 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
43 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
51 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
47 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
21 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
24 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
39 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
53 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
92 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
32 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 ...
1
vote
1answer
27 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
20 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
74 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
23 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
78 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: ...
0
votes
0answers
33 views

.htaccess clean url to GET variable with WordPress

I'm struggling to get a .htaccess rule to work. I'm trying to cleanup a URL for a WordPress site. Instead of /illustration?rid=123, I'd like /illustration/123. I've tried solutions from many of the ...
1
vote
1answer
81 views

Redirect to remove everything after the second slash (first directory)

I'm trying to redirect a lot of pages on a website I own. There are a few pages indexed and I need to fix them for example: /vloerafwerking/projecttapijt/raamafwerking/ needs to go to /vloerafwerking/...
1
vote
1answer
16 views

Don't allow access to example.com/image/pic.jpg using htaccess

I have two domains for the same website. example.com and example2.com . I don't want the /image/pic.jpg to be accessible for the example.com It means, if someone try to visit example.com/image/pic....
1
vote
1answer
40 views

Add Trailing Slash for certain page types

I would like to add a trailing slash for certain static page types like .html, .asp and .pdf. I tried the following code in .htaccess but it is adding a trailing slash to all types of links. # Force ...
0
votes
0answers
12 views

How to enable .htaccess Gzip? [duplicate]

#Gzip <ifmodule mod_deflate.c> # compress text, html, javascript, css, xml: AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/...
0
votes
0answers
20 views

Redirect IP address to domain using .htaccess [duplicate]

I tried the following .htaccess code to redirect the IP address of my VPS server to my domain, but despite of all efforts it keeps resulting in a 404 error: RewriteEngine on RewriteCond %{HTTP_HOST} ^...
1
vote
1answer
53 views

htaccess rule doesn't work - NET::ERR_CERT_COMMON_NAME_INVALID

This URL: https://mqgmodas.com/rebajas/ Into the .htaccess I have: Redirect 301 https://mqgmodas.com/rebajas/ https://masqguapas.com/rebajas/ Also I have a redirection in my control panel saying ...
0
votes
0answers
26 views

Edit htaccess file to remove the slash at the end without disturbing https settings [duplicate]

My website URL has a slash at its end and appears like this https://mywebsite.com/ Since search engine reads https://mywebsite.com/ and https://mywebsite.com as two different URLs, I want to ...
3
votes
0answers
33 views

Why are my HTML resources re-downloading despite having an expiration date a month in the future?

I have set the expiration information for my resources in the .htaccess file as shown below: <IfModule mod_expires.c> ExpiresActive on ExpiresByType image/jpeg "access plus 1 month" ...
1
vote
1answer
52 views

htaccess category seo url redirecting to 404 page in localhost [closed]

I am trying to edit my htaccess. All urls working fine on server, but same htaccess setup redirecting category/cat_name/ url to 404 page without giving any error. all other urls working fine accept ...
2
votes
1answer
127 views

Return 410 gone status code for URLs containing same characters in .htaccess

My website was hit by the pharma spam attack which created hundreds of URLs, all of which contain the last 5 characters -1234.pdf. So that Google and other search engines will remove these quicker, ...
1
vote
1answer
34 views

how to redirect lower case to upercase

I have a WordPress blog and I made subfolder like this https://example.com/Tourism but when I open this URL with lowercase "t" it shows me 404 not found error: https://example.com/tourism this ...
2
votes
1answer
39 views

Redirecting /page/*/ to the home page in .htaccess

My problem is that my homepage exists on https://www.example.com/page/2/, /3/, /4/ and so on, it still exists on /1000/. Same duplicate page versions exists on /about and and /contact page of my site. ...
1
vote
1answer
57 views

.htaccess rewrite conditions for https:// pre tag subdomains

I need some extra code in my .htaccess file that configures this HTTP request for HTTPS too! <ifmodule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^(.*)\.example\.com RewriteRule ^...
2
votes
1answer
233 views

.htaccess redirect with all parameters

I have a simple rule in the .htaccess file, to redirect all requests to inwork.php: RewriteRule .* php/inwork.php?refpage=%{REQUEST_URI} [L] But all parameters are missing. For the request http://...
2
votes
1answer
275 views

.htaccess - How to properly disable the execution of scripts in a folder?

I have this folder path: pulic_html/user/269851516/in the folder /user/ i have many subfolders that is created when the user create a account, and they can upload avatars to this folder, i want to ...
0
votes
2answers
52 views

htaccess - Blocking IPs - Hidden and / or spoofing(?)

.About a month ago my website was hacked. I was alerted to that by Google Adwords because a random scan of my site indicated that it had inappropriate content and / or links to inappropriate content ...
1
vote
2answers
94 views

How secure is an .htaccess file?

I am creating a new website and I want to make it as secure as possible. I was preparing to do some things with .htaccess and I'm semi-concerned about the security level it provides. Can someone (ex: ...
1
vote
1answer
33 views

How is the mapping done from …/script.php?one,1 to …/script/one/2?

There is a PHP script which evaluates one or two parameters via QUERY_STRING. This script should process the parameters via QUERY_PATH. The PHP file type should be omitted. Request of the form https:/...
1
vote
1answer
173 views

How to redirect all url to https except one?

# Go to https if not on firmware RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} !^/firmware$ [NC] RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] # Go to http if you are on firmware ...