Hack Forums
[Help] Affect Subdomain ONLY [.htaccess] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Webmasters (https://hackforums.net/forumdisplay.php?fid=141)
+---- Forum: Website Construction (https://hackforums.net/forumdisplay.php?fid=50)
+---- Thread: [Help] Affect Subdomain ONLY [.htaccess] (/showthread.php?tid=6039131)



[Help] Affect Subdomain ONLY [.htaccess] - draxyee - Jan 8, 2020

I have:

https://example.com

and

https://tools.example.com

I want it so that whenever I visit : https://tools.example.com/test.html, it brings me to https://tools.example.com/test

So basically I want to remove the html extension from the subdomain.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]

This only works for the domain, not the subdomain ^


RE: [Help] Affect Subdomain ONLY [.htaccess] - KnownSyntax - Jan 12, 2020

You need to use the following and it should work.

Code
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]



RE: [Help] Affect Subdomain ONLY [.htaccess] - Porn - Jan 13, 2020

(Jan 12, 2020 08:16 PM)KnownSyntax Wrote:  You need to use the following and it should work.

Code
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

Incase that didnt work op try this:

Code
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

nano /etc/apache2/sites-available/000-default.conf

and paste the following code at the bottom:
Code
<Directory /var/www/>
   Options Indexes FollowSymLinks MultiViews
   AllowOverride all
   Order allow,deny
   allow from all
</Directory>

sudo a2enmod rewrite
sudo service apache2 restart