Home >> Redirect Using htaccess

Category: How To

Redirect Using htaccess

To redirect using .htaccess file use the following code

Redirect 301 / http://example.com/

Or use this to redirect only specific page

Redirect 301 /old-url http://example.com/new-url

Change 301 (permanent) with 302 (temporary) to suit your need.

MySQL Basic Command Cheat Sheet

# Create user
CREATE USER 'username'@'hostname' IDENTIFIED BY 'mypassword';

# Show user
SELECT username FROM mysql.user;

# Grant privilege
GRANT ALL PRIVILEGES ON *.* TO 'username'@'hostname';
Or
GRANT SELECT, INSERT, UPDATE, DELETE ON database.table TO 'username'@'hostname'

# Revoke / remove privilege
REVOKE ALL PRIVILEGES ON object FROM username

# Dump data
mysqldump -h hostname -u root -p databasename > filename.txt

# Import data
mysql -u username -p databasename < sqlfile.sql

# Alter to fulltext
ALTER TABLE tablename ADD FULLTEXT(fieldname);

# Alter character set and collation, CONVERT change all columns
ALTER TABLE tablename CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

# Show character set of a table
SHOW FULL COLUMNS FROM tablename

# Show table option when creating that table
SHOW CREATE TABLE tablename;

# Show all table status
SHOW TABLE STATUS;

Password Protect Directory With .htaccess

To create authentication using htaccess do the following:

  1. Open up console and type htpasswd -c .htpasswd username to create .htpasswd file.
    or alternatively you can search for .htpasswd generator online
  2. Put the newly created .htpasswd file somewhere hidden.
  3. Create .htaccess file with the following content:
    AuthType Basic
    AuthName "Any title you want"
    AuthUserFile /path/to/.htpasswd
    require valid-user
  4. Put the .htaccess file inside the directory you want to password protect

Create Hotspot Using Ubuntu

Assuming you already know how to setup new wifi connection.

  1. Disable wifi
  2. Create new wifi connection from network connection
  3. Type in your preferred hotspot name on SSID
  4. Open /etc/NetworkManager/system-connection/[wifi file name]
  5. Change mode=infrastructure to mode=ap
  6. Save, enable wifi, and connect to your newly created hotspot SSID above.

Enable Apache2 Mod Rewrite on Ubuntu

To enable Apache2 mod rewrite, write the following command on console:
a2enmod rewrite

Edit /etc/apache2/apache2.conf
and search for this code:

<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>

Change AllowOverride None to AllowOverride All

And lastly restart Apache:
service apache2 restart