Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

2 votes
1 answers
4891 views
Redirect Main domain and subdomain from http to https
i want to redirect these sub domains and main domain from http to https and sub blogs too. **Home directories** - WWW (Wordpress): `/home1/placehq5/public_html/.htaccess` - My Somadome (PHP): `/home1/placehq5/public_html/my` - Kiosk site (HTML): `/home1/placehq5/public_html/kiosk` Webserver is Apach...
i want to redirect these sub domains and main domain from http to https and sub blogs too. **Home directories** - WWW (Wordpress): /home1/placehq5/public_html/.htaccess - My Somadome (PHP): /home1/placehq5/public_html/my - Kiosk site (HTML): /home1/placehq5/public_html/kiosk Webserver is Apache version 2.2.31 (on Linux) please correct this htaccess file. RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://somadome.com/$1 [L,R=301] RewriteCond %{SERVER_PORT} 443 RewriteCond %{HTTP_HOST} ^www[.].+$ RewriteRule ^(.*)$ https://somadome.com/$1 [L,R=301] in this picture first column is how my urls are right now, 2nd column is what i want after htaccess rules, 3rd coulmn is what iam getting after applying these rule below:- enter image description here
Navdeep.D2 (35 rep)
May 8, 2017, 07:36 PM • Last activity: Jun 30, 2025, 06:05 PM
0 votes
1 answers
4135 views
How to allow pdf files in .htaccess?
I have this following codes in my htaccess file, but it doesn't allow pdf file to open, it will redirect to 404 page. how can I allow pdf files to open based on my following htaccess file. RewriteEngine on RewriteCond $1 !^(index\.php|images|public|assets|uploads|themes|updates|asset|mob|robots\.txt...
I have this following codes in my htaccess file, but it doesn't allow pdf file to open, it will redirect to 404 page. how can I allow pdf files to open based on my following htaccess file. RewriteEngine on RewriteCond $1 !^(index\.php|images|public|assets|uploads|themes|updates|asset|mob|robots\.txt\.pdf) RewriteRule ^(.*)$ index.php?/$1 [QSA,L] Header set Cache-Control "max-age=604800, public" I highly appreciate your help. Thank
Jona (1 rep)
Dec 31, 2017, 05:56 AM • Last activity: Apr 28, 2025, 03:05 PM
0 votes
0 answers
49 views
Help needed with .htaccess
I have a website which needs to be changed from Nginx to Apache webserver. The index directory is `nl.html` but the HTML extension is removed from the address bar. If I visit the website `example.com` it shows in the address bar the following URL: `example.com/nl` but actually it's `nl.html`. At the...
I have a website which needs to be changed from Nginx to Apache webserver. The index directory is nl.html but the HTML extension is removed from the address bar. If I visit the website example.com it shows in the address bar the following URL: example.com/nl but actually it's nl.html. At the moment I have the following .htaccess
RewriteEngine On
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*)\.html$ $1 [R=301,L]
When I visit the website the root URL is shown without the /nl. If I visit /nl/blog it shows a 404 but it should show /nl/blog.html the issue also appears on other files. What am I missing here?
Noob (161 rep)
Jun 25, 2024, 08:07 PM • Last activity: Jun 25, 2024, 08:52 PM
1 votes
2 answers
446 views
Not working `<Location/>` tag in Apache Virtual host
I am trying to create Apache virtualhost that is closed for all IP addresses with exception of one IP address and two URLs that should be publicly accessible. ServerName example.com ServerAdmin hello@deriva.cz DocumentRoot "/var/www/example.com/app/webroot" Options FollowSymLinks Includes ExecCGI Al...
I am trying to create Apache virtualhost that is closed for all IP addresses with exception of one IP address and two URLs that should be publicly accessible. ServerName example.com ServerAdmin hello@deriva.cz DocumentRoot "/var/www/example.com/app/webroot" Options FollowSymLinks Includes ExecCGI AllowOverride All ErrorDocument 403 "https://example.com/403.php " DirectoryIndex index.php Require all granted Require all granted Require ip 1.2.3.4 SSLProxyEngine on ProxyPreserveHost On ProxyRequests Off ProxyPass /api/ https://host.docker.internal:8443/api/ connectiontimeout=5 timeout=300 ProxyPassReverse /api/ https://host.docker.internal:8443/api/ SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf I've tried to change order of Location tags, but all requests are redirected to ErrorDocument directive value. URL /foo/bar/ is rewrited by .htaccess located in DocumentRoot (for testing purposes I tried to remove .htaccess with no effect). Apache version: - Server version: Apache/2.4.59 (Debian) - Server built: 2024-04-05T12:02:26 Apache runs in a Docker container, but it probably has no meaning for the problem. Q: What is wrong with the configuration?
jnemecz (161 rep)
May 24, 2024, 01:40 PM • Last activity: May 30, 2024, 07:46 AM
0 votes
1 answers
548 views
How to generate index.html for each directory under /var/www/html
I have downloaded confluent software for upgrade under `/var/www/html` directory. I need to create an index.html for directory listing for each directory. I tried adding below to `.htaccess` file in the directory (I saw it somewhere, where the `index.html` existed with files in the directory), but i...
I have downloaded confluent software for upgrade under /var/www/html directory. I need to create an index.html for directory listing for each directory. I tried adding below to .htaccess file in the directory (I saw it somewhere, where the index.html existed with files in the directory), but it did not work:
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
Is there a utility or tool that will allow me to do that? Someone asked me to create it manually, but I don't really want to create it manually. **UPDATE** @Ipor Sircer / @Marcus Müller I updated the httpd.conf file - now it is like below:
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html"

#
# Relax access to content within /var/www.
#

    AllowOverride None
    # Allow open access:
    Require all granted


# Further relax access to the default document root:

    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options 
    # for more information.
    #
    Options +Indexes +FollowSymLinks
    IndexOptions +FancyIndexing +HTMLTable

    #Options None

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    #AllowOverride None
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
This is under /var/www/html:
pwd
/var/www/html

drwxr-xr-x 5 root root  86 Nov  7 18:10 .
drwxr-xr-x 4 root root  33 Aug 12 15:33 ..
drwxr-xr-x 4 root root  46 Nov  6 13:35 clients
drwxr-xr-x 3 root root  55 Nov  6 19:52 packages.confluent.io
drwxr-xr-x 3 root root  17 Nov  6 15:57 rpm
But when I go to the server, I get the below: ![http://server](https://i.sstatic.net/m4Z4a.png) Whereas if I go to server/rpm, I get this: ![http://server/rpm](https://i.sstatic.net/K9c6t.png) What else do I need to change, so I can see the directory under /var/www/html from the browser?
adbdkb (103 rep)
Nov 7, 2023, 08:50 PM • Last activity: Nov 9, 2023, 04:05 PM
2 votes
1 answers
1932 views
php_value settings in .htaccess
I am in the process of migrating an Apache WordPress site from CentOS7 to AlmaLinux9. I installed standard LAMP stuff on the AlamLinux9 system, and restored the MySQL and copied over the html directory. When I hit the site it throws a `500 Internal Server Error` I've narrowed it down to the `php_val...
I am in the process of migrating an Apache WordPress site from CentOS7 to AlmaLinux9. I installed standard LAMP stuff on the AlamLinux9 system, and restored the MySQL and copied over the html directory. When I hit the site it throws a 500 Internal Server Error I've narrowed it down to the php_value settings in the .htaccess file as the source of the error.
php_value post_max_size 32M
php_value upload_max_filesize 32M
php_value max_execution_time 30
php_value memory_limit 256M
php_value error_log "/var/www/html/mysitename.com/php_errors.log"
If I comment out any of the above lines it loads fine. PHP on both is Version 7.4.33 I've verified the php.ini files are also identical. The CentOS system loads fine as is, but the AlamaLinux won't allow it. What else is causing the PHP to not like the setting here in the .htaccess file?
TexasTim (23 rep)
Jun 5, 2023, 10:17 PM • Last activity: Oct 29, 2023, 05:05 PM
-1 votes
2 answers
141 views
allow display and or execution of web files but not direct url access using htaccess
**What I want to Achieve is:** I want to be able to display the (`mp4` | `jpg` | `ico`) file types and execute the (`js` | `css`) file types on the browser only on my domain but I dont want them to directly access those files thru typing the URL on browser address bar. **What I expect and done is**...
**What I want to Achieve is:** I want to be able to display the (mp4 | jpg | ico) file types and execute the (js | css) file types on the browser only on my domain but I dont want them to directly access those files thru typing the URL on browser address bar. **What I expect and done is** Being familiar with PHP $_SERVER['HTTP_REFERER'], I get a URL like http://domainname.xyz/main.php but I do not know if the same goes with .htaccess. Because with .htaccess, the HTTP_REFERER, uses a regex pattern like ^https?://(www.)?domainname\.xyz/.*$ but if I use the pattern the URL as https?://(www.)?domainname\.xyz/main.php that I can hard code that exact URL on .htaccess. Such URL causes error thus I followed the code from sites and incorporated those to my script. I am not expert on htaccess regex. **So I have the .htaccess below as researched result and followed from various sites:** RewriteEngine On RewriteCond %{HTTP_REFERER} !^https?://(www.)?domainname\.xyz/.*$ [NC] RewriteRule \.(jpg|js|css|mp4)$ - [NC,F,L] Also I tried using the code below followed from various sites too: SetEnvIf Referer "!^https?://(www.)?domainname\.xyz/.*$" localreferer Require env localreferer **What is currently happening with the above code is:** With the above .htaccess scripts, only the mp4 file types is displayed on the browser and cannot be directly access using thru the URL on the browser address bar and showing 403 Forbidden error. All other files types are displayed/executed on the browser and they are also directly accessed on the address bar using the URL. **Help** I seek your help on this because I am not an expert on htaccess, regex. I have researched for days now and still no fix. With your help, it will add to my knowledge.
genesis lubrigas (19 rep)
Sep 12, 2023, 05:38 AM • Last activity: Sep 15, 2023, 09:09 AM
4 votes
3 answers
24466 views
How to zip all files including hidden files to zip file using linux command?
I have linux hosting and wanted to zip everything in one single zip file but all time .htaccess file is excluded and other hidden files are not adding to zip file.
I have linux hosting and wanted to zip everything in one single zip file but all time .htaccess file is excluded and other hidden files are not adding to zip file.
Parth Kundariya (61 rep)
Feb 9, 2018, 11:28 AM • Last activity: Aug 16, 2023, 11:02 AM
7 votes
3 answers
23255 views
Authenticate users via LDAP using nginx
I know how to auth the users via LDAP in apache2: # put the following in the VirtualHost ServerAdmin user1@bar.foo.com DocumentRoot /var/www AuthType Basic AuthName "Please provide USERNAME AND PASSWORD" AuthBasicProvider ldap Order allow,deny Allow from all AuthLDAPURL "ldaps://ehh.foo.com/ou=ehh,o...
I know how to auth the users via LDAP in apache2: # put the following in the VirtualHost ServerAdmin user1@bar.foo.com DocumentRoot /var/www AuthType Basic AuthName "Please provide USERNAME AND PASSWORD" AuthBasicProvider ldap Order allow,deny Allow from all AuthLDAPURL "ldaps://ehh.foo.com/ou=ehh,o=foo.com?mail" Require valid-user Require ldap-attribute emailAddress=someuser@bar.foo.com **Q:** But we need to use nginx. How can we configure nginx to auth via LDAP? Using Ubuntu 12.04.5
thequestionthequestion (345 rep)
Nov 2, 2014, 10:11 AM • Last activity: Sep 16, 2022, 12:12 AM
0 votes
0 answers
65 views
How to configure Apache for Authentication
i've got a Netgear Readynas 212 and I'm trying to set up a directory isting for a share. Shares are located in /data/, where /data/share/ is the folder supposed to be listed. On the NAS initial Share on web access is the /data/share/ > /etc/apache2/sites-available/000-default.conf ServerAdmin webmas...
i've got a Netgear Readynas 212 and I'm trying to set up a directory isting for a share. Shares are located in /data/, where /data/share/ is the folder supposed to be listed. On the NAS initial Share on web access is the /data/share/ > /etc/apache2/sites-available/000-default.conf ServerAdmin webmaster@localhost DocumentRoot /data/share Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny Require all granted ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined With a2ensite 000-default.conf I've set the conf as default Also Rewrite Engine with a2enmod rewrite > .htaccess in /data/share # Apache Autoindex Directives Options +Indexes IndexOptions ShowForbidden IndexOptions FancyIndexing HTMLTable SuppressRules ShowForbidden IndexOptions IconsAreLinks ScanHTMLTitles NameWidth=* DescriptionWidth=* # Autoindex-Strapdown Directives AddType text/plain .md HeaderName HEADER.md ReadmeName README.md # Customize by setting theme and title IndexHeadInsert "conf = {theme: 'cyborg', title: 'Mitarbeiterverzeichnis'}; \ \ " # Icons using Bootstrap's Glyphicon set DefaultIcon Image AddIcon Image ^^BLANKICON^^ AddIcon Image ^^DIRECTORY^^ AddIcon Image .. AddIconByType (TXT,https://10.0.1.222/icons/file.svg) text/* AddIconByType (IMG,https://10.0.1.222/icons/picture.svg) image/* AddIconByType (SND,https://10.0.1.222/icons/music.png) audio/* AddIconByType (VID,https://10.0.1.222/icons/film.png) video/* **I've already downloaded icons and created a folder inside the listing share for them but still get the response .gif missing while debugging with the browser even though I've nowhere set those.** enter image description here I've also tried using ramlmn's Directory Listing , no success. Maybe someone has an idea what im missing
BlackArch.py (1 rep)
Sep 14, 2022, 08:22 AM • Last activity: Sep 14, 2022, 10:14 AM
0 votes
0 answers
82 views
prohibit access to pdf files via URL
Simply I am trying to prevent access to all pdf files on my server from being reached and downloaded using URL Eg https://domain.com/test.pdf . What I succeed to do is : to prevent indexing them, but it still accessible via URL. **What I've tried so far :** in both files *mywebsite.conf, apache2.con...
Simply I am trying to prevent access to all pdf files on my server from being reached and downloaded using URL Eg https://domain.com/test.pdf .
What I succeed to do is : to prevent indexing them, but it still accessible via URL. **What I've tried so far :** in both files *mywebsite.conf, apache2.conf*
Require all denied Order allow,deny Deny from all I tried to block the directory as well but did not work.(with/without VirtualHost). I changed **AllowOverride** to **All** in apache2.conf I tried to block them using .htaccess Order Allow,Deny Deny from All still accessible. (Ubuntu 20.04) Any help will be appreciated.
MertHaddad (101 rep)
Aug 13, 2022, 04:31 AM
0 votes
1 answers
310 views
Block access to an URL path by many IPs in .htaccess
I am only able to use `.htaccess` so ` ` and ` ` are not possible. I am currently using this to block access by IP: ```htaccess Require all granted Require not ip 1.0.132.75 Require not ip 1.0.209.198 Require not ip 1.0.209.229 # ... many more IPs ``` I would like to block those many IPs only from a...
I am only able to use .htaccess so ` and ` are not possible. I am currently using this to block access by IP:
Require all granted
  Require not ip 1.0.132.75
  Require not ip 1.0.209.198
  Require not ip 1.0.209.229
  # ... many more IPs
I would like to block those many IPs only from accessing a certain path, namely a PHP login accessible at /typo3/ / /typo3/index.php. But blocking everything under /typo3 would be ok, too. I could certainly use this but I hope that there is a shorter, more concise variant:
RewriteCond %{REMOTE_ADDR} "=1.0.132.75"
RewriteRule "^/typo3" "-" [F]
Well, now that I am writing it I found
RewriteCond %{REMOTE_ADDR} "1\.0\.132\.75|1\.0\.132\.76|..."
RewriteRule "^/typo3" "-" [F]
but that Regular Expression would be very long (~3000 IPs). Probably there are better solutions.
Jonas Eberle (513 rep)
Jun 14, 2022, 10:51 AM • Last activity: Jun 14, 2022, 10:54 AM
0 votes
1 answers
46 views
Add lines in every /home/userxxx/public_html/.htaccess file
I have multiple cpanel websites with this file/dir structure: /home/user0/public_html/.htaccess /home/user1/public_html/.htaccess /home/user2/public_html/.htaccess etc.. And would like to add (not just replace the whole .htaccess ) at bottom of the file couple new lines, such as: # order deny,allow...
I have multiple cpanel websites with this file/dir structure: /home/user0/public_html/.htaccess /home/user1/public_html/.htaccess /home/user2/public_html/.htaccess etc.. And would like to add (not just replace the whole .htaccess ) at bottom of the file couple new lines, such as: # order deny,allow deny from all Is there a way to do that in one bulk process?
Hueznar (15 rep)
May 28, 2022, 01:47 PM • Last activity: May 28, 2022, 02:44 PM
1 votes
1 answers
490 views
.htaccess being ignored by Apache
It seems that the .htaccess file for one of my virtual hosts is being ignored on my production server. The file is identical to working .htaccess files for other vhosts on the same server. Also, the vhost definition is identical to other working vhosts, except, of course, for lines that are specific...
It seems that the .htaccess file for one of my virtual hosts is being ignored on my production server. The file is identical to working .htaccess files for other vhosts on the same server. Also, the vhost definition is identical to other working vhosts, except, of course, for lines that are specific to the respective vhosts. When the problem is occurring, index.php loads correctly for the base URL, but all rewrite directives are ignored. Also, putting garbage in .htaccess doesn't cause an error. The site runs as expected on my backup server, to which websites and Apache config files (with one exception, mods-enabled) are mirrored hourly, and to which databases are replicated. I compared mods-enabled on my backup and production servers, and found that mod_cgid was not enabled in production. Enabling it seemed to fix the problem, but only temporarily. Selectively deleting rewrites from .htaccess brings no success. I'm considering rebuilding my production server. What other troubleshooting is recommended? Are there any known fixes?
dcorsello (131 rep)
Dec 14, 2021, 08:36 AM • Last activity: Dec 21, 2021, 01:46 AM
-1 votes
1 answers
89 views
Problems with .htaccess and slash
I'm trying to solve a problem with .htaccess. I have this lines in my .htaccess, but the website still have a "with slash" version. **Sorry, it's an erotic page** https://carlamila.es/acompanantes-madrid.php/ Thanks in advance!!! #With www to nonwww RewriteCond %{HTTP_HOST} ^www.carlamila.es [NC] Re...
I'm trying to solve a problem with .htaccess. I have this lines in my .htaccess, but the website still have a "with slash" version. **Sorry, it's an erotic page** https://carlamila.es/acompanantes-madrid.php/ Thanks in advance!!! #With www to nonwww RewriteCond %{HTTP_HOST} ^www.carlamila.es [NC] RewriteRule (.*) https://carlamila.es/$1 [R=301,L,QSA] #Http to HTTPS RewriteCond %{HTTPS} off RewriteRule (.*) https://carlamila.es/$1 [R=301,L,QSA] #With to without slash RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule (.*) http://carlamila.es/$1/ [R=301,L,QSA]
Jordi Webmaster (1 rep)
Feb 6, 2021, 09:39 AM • Last activity: Nov 11, 2021, 09:40 PM
0 votes
0 answers
156 views
Weird behavior on reverse proxy by htaccess
I've set up a reverse proxy on my vps by placing the following `.htaccess` file under /var/www/html/ecommerce/app. ``` DirectoryIndex disabled RewriteEngine On RewriteRule ^(.*)$ http://127.0.0.1:3000/$1 [P,L] RewriteRule ^$ http://127.0.0.1:3000 [P,L] ``` localhost:3000 is the local node server run...
I've set up a reverse proxy on my vps by placing the following .htaccess file under /var/www/html/ecommerce/app.
DirectoryIndex disabled

RewriteEngine On 
RewriteRule ^(.*)$ http://127.0.0.1:3000/$1  [P,L] 
RewriteRule ^$ http://127.0.0.1:3000  [P,L]
localhost:3000 is the local node server running on my vps. /var/www/html/ is the document root. So I was expecting, if all goes well, I can load the app via http://my-public-vps-ip/ecommerce/app . But that doesn't work and instead I can load the app via http://my-public-vps-ip:3000 . I don't understand this. Could you help me understand what might be going on?
Logan Lee (249 rep)
Jun 28, 2021, 10:41 PM
0 votes
0 answers
974 views
FilesMatch htaccess syntax pain for apache 2.4
someone please tell me why this doesn't work in .htaccess? #grant access if word-processing format Require all granted #deny access for double file extensions Require all denied If I look at this any longer I'll have pulled all my hair out! So it's not blocking e.g ' extensions.conf' from being uplo...
someone please tell me why this doesn't work in .htaccess? #grant access if word-processing format Require all granted #deny access for double file extensions Require all denied If I look at this any longer I'll have pulled all my hair out! So it's not blocking e.g ' extensions.conf' from being uploaded.. the regex is right so it must be the syntax for Apache 2.4 htaccess.. restrictions in the htaccess above this block are being respected (e.g. no indexing) so the file is being parsed. Does this syntax look correct? *edited to actually ask a question
RussH (1 rep)
May 6, 2021, 03:43 PM • Last activity: May 6, 2021, 06:49 PM
-1 votes
2 answers
101 views
SED for thousand of 301 redirections on htaccess?
I got a headache with URLS after change them on one of my websites. The URLs were very long and I decided to change them despite the later change via .htacces... I'm making the change one by one (I have more than 1500 URLs...) I have this: Redirect 301 /noticies/festes-noticies/diania-roda-les-aixam...
I got a headache with URLS after change them on one of my websites. The URLs were very long and I decided to change them despite the later change via .htacces... I'm making the change one by one (I have more than 1500 URLs...) I have this: Redirect 301 /noticies/festes-noticies/diania-roda-les-aixames-la-nit-de-nadal/ And this becomes: Redirect 301 /noticies/festes-noticies/diania-roda-les-aixames-la-nit-de-nadal/ /diania-roda-les-aixames-la-nit-de-nadal/ The last /-----/, were put at the finish of the line, with one blank space. There are a method with sed or another command to do this easily?
Jordi Webmaster (1 rep)
Nov 15, 2020, 07:07 AM • Last activity: Nov 15, 2020, 03:08 PM
0 votes
1 answers
608 views
can't browse to subdomain on apache server, getting forbidden resource permission
I have cPanelA with website A...with subdomain A1 - all is working correctly. I have created a new cPanelB with website B...and need to move subdomain A1 over to cPanel B as subdomain B1. Website B is working...but after copying all of subdomain A1 over to cPanel B, I can't get subdomain B1 to work....
I have cPanelA with website A...with subdomain A1 - all is working correctly. I have created a new cPanelB with website B...and need to move subdomain A1 over to cPanel B as subdomain B1. Website B is working...but after copying all of subdomain A1 over to cPanel B, I can't get subdomain B1 to work. It keeps returning Forbidden - you don't have permission to access this resource In cPanelB, I have verified all the file/directory ownerships are correct. I verified all the file permissions are correct (0644 on files and 0755 on directories). I verified PHP is enabled for the new cPanel (via WHM). After more than an hour of frustration - I then verified subdomain B1 file structure/permissions/ownership were identical to those on subdomain A1. I copied the .htaccess files from website A and subdomain A1 over to website B and subdomain B - and then changed any domain references to the new B sub/domain. So I don't think its my .htaccess files...they actually seem to be working because the root /www/.htaccess file has a rewrite to point to the subdomain folder /www/club and I can see in the browser that its actually making it to the subdomain B. I know this is probably going to be something tedious but I am all out of ideas on what the issue could be. www/.htaccess: Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^api\. [NC] RewriteRule !^api/ api%{REQUEST_URI} [L,NC] // api.domainB.com RewriteCond %{HTTP_HOST} ^portal\. [NC] // portal.domainB.com RewriteRule !^club/ portal%{REQUEST_URI} [L,NC] Options -Indexes SetEnvIf X-Rquested-With com.domainB domainB #AddType application/x-httpd-php7 .html .htm ErrorDocument 404 https://www.domainB.com/errorpage.html # file upload info DirectoryIndex index.html index.htm index.php AddHandler application/x-httpd-ea-php73 .php .html .htm .phtml # php -- BEGIN cPanel-generated handler, do not edit # Set the “ea-php73” package as the default “PHP” programming language. AddHandler application/x-httpd-ea-php73 .php .php7 .phtml # php -- END cPanel-generated handler, do not edit www/club/.htaccess for: portal.domainB.com RewriteEngine On RewriteCond %{HTTP_HOST} !^portal\. [NC,OR] RewriteCond %{HTTPS} off RewriteRule ^ - [F] #AddType application/x-httpd-php5 .html .htm DirectoryIndex index.html index.htm index.php Header set Access-Control-Allow-Origin "*" AddHandler application/x-httpd-ea-php73 .php .html .php7 .phtml ErrorDocument 404 https://portal.domainB.com/errorpage.html # php -- BEGIN cPanel-generated handler, do not edit # Set the “ea-php73” package as the default “PHP” programming language. AddHandler application/x-httpd-ea-php73 .php .php7 .phtml .html # php -- END cPanel-generated handler, do not edit
rolinger (175 rep)
Sep 25, 2020, 04:20 AM • Last activity: Sep 25, 2020, 11:58 AM
1 votes
0 answers
120 views
Redirect http->https, but exclude subdomain
I use Drupal, with a complicated multi-Domain setup, and have a local development site, that uses (locally) the dev. subdomain. So I want a .htaccess file that can be used on production AND development. The production site is used with HTTPS, and there is a HTTP->HTTPS redirect in the htaccess file....
I use Drupal, with a complicated multi-Domain setup, and have a local development site, that uses (locally) the dev. subdomain. So I want a .htaccess file that can be used on production AND development. The production site is used with HTTPS, and there is a HTTP->HTTPS redirect in the htaccess file. I just want to NOT redirect to https if on the .dev subdomain: RewriteBase / # use website without "www." RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301] # force HTTPS, but don't if on local development site RewriteCond %{HTTPS} !=on RewriteCond %{ENV:HTTPS} !=on RewriteCond %{HTTP_HOST} !^dev\.(.+)$ [NC] RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] But this does not work, and creates a loop redirect. But I can't see why. Any hints?
nerdoc (151 rep)
Apr 18, 2019, 10:57 AM • Last activity: Jul 30, 2020, 07:21 PM
Showing page 1 of 20 total questions