0

Apache2 rewrite rules are not working

You have just edited your .htaccess on the root of your new site with RewriteRules and it’s not working. Something like this for a WordPress installation

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

There are two reasons for this to happen. The mod_rewrite is not enabled by default and your configuration may not allow the use of .htaccess

Enabling mod_rewrite

As I usually don’t mess with Apache I often forget it has a command to enable modules. It’s just like this.

sudo a2enmod rewrite

Enabling .htaccess files

Edit your site configuration file under /etc/apache2/sites-available/. At the Directory entry for your site files you need to allow the reading of directives in .htaccess files.

If you were editing the default site

        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

you would have to use AllowOverride FileInfo or even AllowOverride All. It’s your choice.

Get it to work

Finally you have to restart the Apache server to activate the changes

sudo service apache2 restart

That’s it!

0

Disabling IPv6 in MacOS X or Linux

You may be experiencing slow internet for certain sites if you have a router that doesn’t work well with IPv6 (Fritz, Hitron) or doesn’t allow you to change its DNS settings. You are having name resolution time outs.

I’m assuming you only want IPv4 :-)

The straightforward solution is just to disable IPv6 on your machine.

How to disable ipv6 in MacOS X

If you have Leopard or Snow Leopard (10.5 or 10.6) click Apple / System Preferences / Network. Choose Ethernet or Airport and then Advanced / TCP/IP. Choose off on Configure IPv6.

For Lion or Mountain Lion (10.7 or 10.8) first open a Terminal. To know the name of the network interface you want to edit type

$ networksetup -listallnetworkservices

And then disable IPv6 like this, for example,

$ networksetup -setv6off Wi-Fi

Want to get back ?

$ networksetup -setv6automatic Wi-Fi

How to disable IPv6 in Linux

Let’s suppose you were using WiFi

$ ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr 00:1e:65:f6:84:f4  
          inet addr:192.168.1.9  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::21e:65ff:fef6:84f4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:34340 errors:0 dropped:0 overruns:0 frame:0
          TX packets:29814 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:25657649 (25.6 MB)  TX bytes:7569224 (7.5 MB)

You can see your interface also is using IPv6.

$  sudo sysctl net.ipv6.conf.wlan0.disable_ipv6=1
[sudo] password for biafra: 
net.ipv6.conf.wlan0.disable_ipv6 = 1

$ ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr 00:1e:65:f6:84:f4  
          inet addr:192.168.1.9  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:34507 errors:0 dropped:0 overruns:0 frame:0
          TX packets:29977 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:25677902 (25.6 MB)  TX bytes:7597685 (7.5 MB)

You can disable it between reboots on /etc/sysctl.conf with this line:

net.ipv6.conf.wlan0.disable_ipv6 = 1

The network problems continue

Really ? Then maybe it’s not an IPv6 issue! :-)

0

Cisco Console via aux Port

You need to use your Cisco through the console, like an enable secret recovery, but you forgot your usb-serial dongle. If you have another Cisco near by with remote access you are safe!

Preparation

Start connecting a Cisco console cable (cross over cable) from the console port of the router (routerc) to the auxiliary port of the helpful router (routerh).

After remotely accessing routerh configure it’s aux line

routerh#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
routerh(config)#line aux 0
routerh(config-line)# transport input telnet
routerh(config-line)#^Z
routerh#

Using the console

We need to know the line number of the AUX port and the IP address of this routerh

routerh#sh line
   Tty Typ     Tx/Rx    A Modem  Roty AccO AccI   Uses   Noise  Overruns   Int
      0 CTY              -    -      -    -    -      0       0     0/0       -
      1 AUX   9600/9600  -    -      -    -    -     13      21     0/0       -
*     2 VTY              -    -      -    -    5    202       0     0/0       -
      3 VTY              -    -      -    -    5      1       0     0/0       -
      4 VTY              -    -      -    -    5   4358       0     0/0       -
      5 VTY              -    -      -    -    5    125       0     0/0       -
      6 VTY              -    -      -    -    5      1       0     0/0       -
 
routerh#

It shows the aux port is on line 1. Our IP address is 192.168.1.1

To access the console you have to telnet your local IP address at port 2000 plus the line number:

routerh#telnet 192.168.1.1 2001
Trying 192.168.1.1, 2001 ... Open
 
routerh line 1 
 
 
User Access Verification
 
Username: biafra
Password: 
[ENTER]
 
routerc line 1 
 
 
User Access Verification
 
Username: biafra
Password: 
 
routerc#

And you are now using the console of routerc. Please note that you may have no console access restrictions as it’s shown here because of AAA.

Suspending and Disconnecting

You can get back to routerh with ctrl-6 x (or ctrl-shift-6 x).

routerh#sh users
    Line       User       Host(s)              Idle       Location
   1 aux 0     biafra     idle                 00:00:13 192.168.1.1
*  2 vty 0     biafra     192.168.1.1          00:00:09 10.0.0.10
 
  Interface    User               Mode         Idle     Peer Address
 
routerh#

Just hitting enter or entering the session number you are connected again to the remote console.

To disconnect just check the aux line with sh users and

routerh#clear line 1
[confirm]
 [OK]
routerh#
[Resuming connection 1 to 192.168.1.1 ... ]
 
[Connection to 192.168.1.1 closed by foreign host]
routerh#
 
routerh#sh users
    Line       User       Host(s)              Idle       Location
*  2 vty 0     biafra     192.168.1.1          00:00:14 10.0.0.10
 
  Interface    User               Mode         Idle     Peer Address
 
routerh#

To remember

Configure the aux port and suspend the console with ctrl-6 x.