Need help with .htaccess redirection for WordPress websites

I am changing the domain of my website.

But, I am struggling with the domain redirection. I need to implement this wildcard redirection.

So that I visit.

https://www.oldomain.com/page1

It should go to

https://newdomain.com/page1

Note: The new domain is without www.

Can anyone help me how to implement this?

Go to Source
Author: Nirmal Kumar

ANSWER

A 301 Redirect, or permanent redirect, is recommended when dealing with something similar to this one.

If you just want to hard redirect anything hitting oldomain.com to newdomain.com then a simple Redirect should do like so:

<VirtualHost *:443>
	ServerName oldomain.com
        ServerAlias www.oldomain.com
	Redirect 301 / https://newdomain.com
</VirtualHost>

The above example is also something that you will want to write in a server config like httpd.conf but not in a .htaccess file somewhere on your site directory. It is also clumsy since your old site’s pages – e.g https://www.domain.com/some/page/123 – will redirect only to https://newdomain.com which is the index page of the site.

So the other option would be Rewrite. It is also in case you don’t have root access to the server, and/or other sites that are not yours are sharing it as well. It would look like the following:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldomain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.oldomain.com [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301,NC]

The above considers whether the request is written with or without the www subdomain in it. The old links or pages will also get carried over to the new one.

Ubuntu 20.04 Does Not Boot

ANSWER

Looks like this one just needs to have their GRUB re-written to MBR again. It’s not so hard. But given that I did something like this 8 years ago… The concept should still be the same. Steps of what I did to fix it here.

I originally had Ubuntu 18.04 installed on my dell xps 13 (2017). A couple days ago, I replaced it with Ubuntu 20.04 due to constant error messages. Until today, I was able to use it without any trouble.
However, I had to use Windows earlier today, and now when I was trying to boot Ubuntu back, I am unable to do so.

First error message

Unexpected return from initial read: Volume Corrupt buffersize 1000 Failed to load image EFIubuntugrubefi: Volume Corrupt start_image() returned Volume Corrupt

and then windows booted automatically.

In trying to resolve the issue,

  1. Tried reinstalling Ubuntu 20.04 using LiveUSB, but got the error saying the system doesn’t have EFI System Partition
  2. Consulted the forum https://ubuntu.forumming.com/question/5394/unexpected-return-from-initial-read-volume-corrupt.
    In running Boot Repair, I received an error message, sayin EFI System Partition is needed.
  3. Used GPart to try to tweak disk settings (changing the disk partition that holds Ubuntu File System from ext4 to fat32… I didn’t document this process very well)
  4. Followed a tutorial that used Windows command prompt and diskpart, creating an ESP.
  5. Reran Boot Repair (successfully this time)

However, now I encountered a GRUB error

“Minimal BASH like line editing is supported. For the first word, TAB lists possible command completions. anywhere else TAB lists possible device or file completions.”

I’ve been looking up different solutions, but I am having trouble understanding them, and afraid I am messing my disk more and more.

Thank you in advance.

Go to Source
Author: Amanda Jeong

how to get specific character from a log file in linux

ANSWER

Assuming that (1) the log file looks as it is AND (2) it is multi-line, then a simple Linux grep command like below should work (even with multiple lines of that line you’re looking for in one log file):

INPUT | Tested it on dummy logs from sample

COMMAND | grep -Pn "^Id\s+:\s+(.*)$" *.log

OUTPUT |

log101.log:2:Id : UN123P

log102.log:2:Id : HELLO321

log103.log:2:Id : STUDE23P

log104.log:2:Id : Lorem

log104.log:7:Id : IPsum

log104.log:12:Id : Dolor

have a log file , having multiple contents inside the file like and example below is the content of U123.log . I have n number of logs..

Accepted password for hoover from 10.0.2.2 port 4792 ss

Id : UN123P 

ID_MTCH : UnixProduction

Accepted password for hoover from 10.0.2.2 port 4792 ss

Accepted password for hoover from 10.0.2.2 port 4792 ss

Is there any we can fetch “Id : UN123P” as an output of linux command. We have some 1000’s of logs and from all the logs , trying to fetch the value only starts with ID : and output as “Id : UN123P”

Pls suggest

Go to Source
Author: Arya

Linux box becomes unresponsive over network when local user logs out [closed]

So, my dad insists on hosting his own website from his own home computer. I set this up on a Linux Mint box, using a very simple server written in Go and this worked fine for years. Recently the setup has developed the fault that when he logs out of his local session on the machine (some GUI desktop environment like Gnome, whatever linux mint comes with) then the web server stops responding to external requests. The SSH daemon is also unresponsive externally.

The only thing I can think of is maybe the machine goes into some kind of power saving mode because it thinks its not needed due to having no local user.

Any ideas how to investigate or fix this?

Thanks!

Go to Source
Author: felix

How to reproduce SQL Injection problem by sending single quote in MySQL?

This is Damn Vulnerable Web Application (DVWA) and it’s vulnerable to SQL injection (SQLi).

Let’s begin by sending normal request

http://127.0.0.1/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#

Output via browser

ID: 1
First name: admin
Surname: admin

This is how the request looks like in MySQL

mysql> SELECT first_name, last_name FROM users WHERE user_id = '1';
+------------+-----------+
| first_name | last_name |
+------------+-----------+
| admin      | admin     |
+------------+-----------+
1 row in set (0.00 sec)

mysql> 

Common way to identify SQL injection is by sending single quote ' char in the parameter.

E.g. id='

Give it a try on the url and it works.

http://127.0.0.1/dvwa/vulnerabilities/sqli/?id='&Submit=Submit#

Web browser will display SQL error indicates that the site is vulnerable to SQLi

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''''' at line 1

I didn’t know how the query looks like in MySQL ..

So I’ve tried SELECT first_name, last_name FROM users WHERE user_id = '''; but I didn’t get the same error.

Instead, I was getting '> symbol from MySQL shell.

mysql> SELECT first_name, last_name FROM users WHERE user_id = ''';
    '> 
    '> 
    '> '
    -> 
    -> ;
Empty set (0.00 sec)

mysql> 

What is the right way to query id=' or user_id = ' (single quote) request in MySQL?

Go to Source
Author: Wolf

How to “ignore” syncing of specific photos with Google Photos?

I have Google Photos on my iOS device. It has successfully synced most of my photos, but there are about 120 old photos that for one reason or the other it cannot sync (it doesn’t give me specifics, it just tells me it cannot sync the photo).

I don’t much care if those photos actually get synced, but I would like to remove them from the queue of photos to be synced (they never go away). I would like to tell Google Photos to just “ignore” those photos, but I cannot find a way to do this.

I considered deleting the photo from Google Photos, but it wanted to also delete the photo from my iOS device when I performed this action, and I do not consider this an acceptable alternative.

Is there a way to instruct Google Photos to ignore a photo when attempting to sync? (bonus if it can be done in bulk)

Go to Source
Author: SethMMorton

Wifi disconnects automatically after sometime

My WiFi disconnects automatically after sometime and is working again only after a reboot.

Here is the result of lshw -C network

  *-network
       description: Ethernet interface
       product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:02:00.0
       logical name: eno1
       version: 15
       serial: 80:ce:62:7c:c1:77
       capacity: 1Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=r8169 firmware=rtl8168h-2_0.0.2 02/26/15 latency=0 link=no multicast=yes port=MII
       resources: irq:16 ioport:4000(size=256) memory:b1104000-b1104fff memory:b1100000-b1103fff
  *-network DISABLED
       description: Wireless interface
       product: RTL8723DE 802.11b/g/n PCIe Adapter
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:03:00.0
       logical name: wlo1
       version: 00
       serial: 40:9f:38:f7:ca:8f
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress cap_list ethernet physical wireless
       configuration: broadcast=yes driver=rtw_pci driverversion=5.4.0-33-generic firmware=N/A latency=0 link=no multicast=yes wireless=IEEE 802.11
       resources: irq:130 ioport:3000(size=256) memory:b1000000-b100ffff

and here is result of iwconfig

wlo1      Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:off

i am using ubuntu 20.04

EDIT: output of rfkill list all

0: phy0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
1: hci0: Bluetooth
    Soft blocked: no
    Hard blocked: no

Go to Source
Author: parv desai

load_plugin_textdomain was called with an argument that is deprecated since version 2.7.0 with no alternative available

I tried to update Avada theme using ftp. I deleted Avada folder and copied that again from zip file I downloaded. Since then, I am facing these errors:

    Deprecated: load_plugin_textdomain was called with an argument that is deprecated since version 2.7.0 with no alternative available. in /home/avang/domains/avang.ir/public_html/wp-includes/functions.php on line 5007

Deprecated: load_plugin_textdomain از نگارش 2.7.0 از رده خارج شده و هیچ جایگزینی برای آن وجود ندارد. in /home/avang/domains/avang.ir/public_html/wp-includes/functions.php on line 5007

Deprecated: has_cap از نگارش 2.0.0 از رده خارج شده! استفاده از رده‌های کاربر، منسوخ شده است. از قابلیت‌ها (capabilities) به جای آن استفاده نمایید. in /home/avang/domains/avang.ir/public_html/wp-includes/functions.php on line 4997

Deprecated: has_cap از نگارش 2.0.0 از رده خارج شده! استفاده از رده‌های کاربر، منسوخ شده است. از قابلیت‌ها (capabilities) به جای آن استفاده نمایید. in /home/avang/domains/avang.ir/public_html/wp-includes/functions.php on line 4997
Deprecated: contextual_help از نگارش3.3.0 منسوخ شده است! به‌جای آن از get_current_screen()->add_help_tab(), get_current_screen()->remove_help_tab() استفاده نمایید. in /home/avang/domains/avang.ir/public_html/wp-includes/functions.php on line 5088
    Notice: Undefined offset: 0 in /home/avang/domains/avang.ir/public_html/wp-content/plugins/wp-parsidate/includes/fixes-permalinks.php on line 246

Notice: Undefined offset: 1 in /home/avang/domains/avang.ir/public_html/wp-content/plugins/wp-parsidate/includes/fixes-permalinks.php on line 247

Notice: Undefined offset: 2 in /home/avang/domains/avang.ir/public_html/wp-content/plugins/wp-parsidate/includes/fixes-permalinks.php on line 248

could somebody help please?

Go to Source
Author: Arya

Moving Files After Conversion to pdf

I have created a linux script to convert files from .odt to .pdf
But the script after converting moves files into same dir where script is executed. As script is recurring I want files to stay in the same where originals are.
Here is the script.

#!/bin/bash
​
for file in $(find -type f -name '*.odt')
do
    echo $file
    libreoffice --headless --convert-to pdf $file
    #libreoffice --headless --convert-to pdf $file
done
​
​
#find -type f -name '*.odt' -print0 | xargs -0 libreoffice --headless --convert-to pdf

I have tried setting --outdir to be path of directories but it moves all files to those directories. I want converted files to stay in same directory as original files.

Go to Source
Author: SahilM

How can I configure ZSH to start each shell with an isolated, empty history?

I use ZSH with Oh My Zsh. I would like each new ZSH shell to start with an empty history. Commands typed in one shell should never show up in the history of another shell. How can I achieve this?

I’ve tried appending the following to my ~/.zshrc to no avail:

setopt no_share_history
unsetopt share_history
unsetopt inc_append_history
unsetopt append_history

I have also tried following this answer to make the arrow keys only show local history, but that seemed to have no effect.

Currently, if I open a new shell, it imports history. I cannot seem to delete the history; when I delete ~/.zsh_history, it re-appears with the entire old content once I open a new shell. inc_append_history does prevent history from being written right away, but the history will still eventually be saved once the shell is closed.

Go to Source
Author: bgfvdu3w

How to “trust” data that is posted from one application to other

We have a use case where a bunch of data needs to be posted from our application to a partner site where the end user takes some actions and then returns back to our site. On the return, the partner site also posts some data back to us. We need to establish trust for both the redirects.. i.e. the partner site needs to confirm that the data is originated at our end and hasn’t been modified during the transmission nd the same applies for post back from partner site. Our main constraint is that it should be a low cost solution for our partners. Our application is a multi-tenanted app with various partners (dozens). The usecase is applicable for all of them.

One option we looked at is a two step process, where our site posts a unique transaction id to the partner site which then calls a webservice hosted by us to get the complete data. We can secure our webservice using 2-way SSL auth and same goes for the data from the partner site. But the problem with the extra cost involved in creating a webservice at each partner end. This would delay the onboarding of a new partner and increase the cost.

Are there other alternatives to this problem than the PKI based solution?

Go to Source
Author: RKodakandla

Trying to Update an list inside a forum using arrayForm

I’m trying to update my playlist form that contains normal input and an arrayform that contains a list of songs.
when I try to change the two input it works but when I try to change anything in the array all the songs inside the playlist get deleted

before updating the array list:

enter image description here

after I press on edit here’s what I get:

enter image description here

and when I try changing anything in the ArrayList I get this

enter image description here

and when I try to edit it once more I get this
enter image description here
and an error :

ERROR TypeError: Cannot read property ‘map’ of undefined

I will leave bellow all the function I used :
this in my main component:
editPlaylist(playlist: Playlist, index: number) {
const dialogRef = this.dialog.open(DialogComponent, {
width: ‘900px’,
data: {
songs:this.songs,

        operation: 'edit',
        playlistData: playlist,
        position: index
      }
    });

    dialogRef.afterClosed().subscribe(result => {
      if (result) {
         this.playlists[index] = playlist;
        this.songs= result.song;
        this.playlists[index].name = result.name;
        this.playlists[index].description = result.description;



        this.playlists[index].songs = result.song;

      }
    });
  }

and this in my dialog componenets
ngOnInit(): void {

   this.form = new FormGroup(
      {
        name:new FormControl('', Validators.required),
        description:new FormControl('',Validators.required),
        title:new FormControl('',Validators.required),
        artist:new FormControl('',Validators.required),
        duration:new FormControl(0,[Validators.required , Validators.min(0)]),
        songs:  this.formBuilder.array([ this.createSong() ])


      }
    )
    if (this.data.operation === 'edit') {
      this.form = this.formBuilder.group({
        name: [this.data.playlistData.name, Validators.required],
        description: [this.data.playlistData.description, Validators.required],
        songs: this.formBuilder.array(
          this.data.playlistData.songs.map(song => this.formBuilder.group({
            title: [song.title, Validators.required],
            artist: [song.artist, Validators.required],
            duration: [song.duration, Validators.compose([Validators.required, Validators.min(0)])],
          }))
        ),
      })

    }
      }

please if someone is familiar with arrayform help me

Go to Source
Author: Nisrine Hafi

Corrupted ext4 disk with windows disk manager

I am the main linux person in our team (which is a sad state of affairs), and am trying to fix a problem created by one of our windows users.

They had a 5TB drive with a single ~5TB ext4 partition with a bunch of video files. They weren’t the one who set up the drive, so when they couldn’t access it in windows they went into disk manager and ” converted to GPT” in windows disk manager. Now it isn’t accessible in ubuntu either.

Disk: Seagate ST5000DM

fdisk reports: the wrong disk size

Disk /dev/sdg: 561.5 GiB, 602934566912 bytes, 1177606576 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xa6985519

Testdisk reports the wrong disk size: >Disk /dev/sdg – 602 GB / 561 GiB – ST5000DM 000-1FK178

fsck reports:

fsck from util-linux 2.31.1
e2fsck 1.44.1 (24-Mar-2018)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks…
fsck.ext2: Bad magic number in super-block while trying to open /dev/sdg

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem. If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193
or
e2fsck -b 32768

Found a PMBR partition table in /dev/sdg

Gdisk reports:
Caution: The CRC for the backup partition table is invalid. This table may
be corrupt. This program will automatically create a new backup partition
table when you save your partitions.

Problem: The secondary header’s self-pointer indicates that it doesn’t reside
at the end of the disk. If you’ve added a disk to a RAID array, use the ‘e’
option on the experts’ menu to adjust the secondary header’s and partition
table’s locations.

Problem: Disk is too small to hold all the data!
(Disk size is 1177606576 sectors, needs to be 9767541168 sectors.)
The ‘e’ option on the experts’ menu may fix this problem.

Problem: GPT claims the disk is larger than it is! (Claimed last usable
sector is 9767541134, but backup header is at
9767541167 and disk size is 1177606576 sectors.
The ‘e’ option on the experts’ menu will probably fix this problem

Problem: partition 1 is too big for the disk.

Partition(s) in the protective MBR are too big for the disk! Creating a
fresh protective or hybrid MBR is recommended.

Identified 6 problems!

File recovery programs can still read the files, so I can fall back on that if I have to, but it will take forever and lead to endless sorting and renaming of files. I am hoping I can ” fix” the partition table to be able to mount the drive and immediately back up the data onto a secure, backed up location.

Thanks for any assistance. Any guidance on what to try is appreciated. I haven’t had to deal with this kind of thing before, my linux usage is pretty vanilla.

Go to Source
Author: Chris Hall

validationRegex to accept/validate listed characters

5 to 16 alpha or alphanumeric to include special characters such as:
◦*Hyphen ( – )
◦*Slash ( / )
◦*Backslash ( )
◦*Asterisk ( * )
◦*Dollar Sign ( $ )
◦*Period ( . )
◦*Ampersand ( & )
◦*Comma ( , )
◦*Number Sign ( # )
◦*Open Parenthesis ( ( )
◦*Closed Parenthesis ( ) )
◦*Colon ( : )

Current code example:

PASSWORD: {id: password, label: PASSWORD, name: PASSWORD, validationRegex: ^[a-zA-Z0-9]+$, minLength: 5, maxLength: 16, errorMsg: message}

Go to Source
Author: Marcus

Why can’t expose my local port publicly with ssh remote forwording via vps?

I build a simple web on local pc,want to expose my local port with ssh remote forwording via my vps.
Setting in my vps.

vim /etc/ssh/sshd_config
GatewayPorts yes
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes

systemctl restart sshd

Open port 8001 on my vps.

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

Build a ssh remote port forwording on my local pc.

ssh -fNR  0.0.0.0:8001:localhost:80  root@vps_ip

Check port 8001 on my vps.

netstat -plant  | grep  8001
tcp        0      0 127.0.0.1:8001          0.0.0.0:*               LISTEN      797/sshd: root      
tcp6       0      0 ::1:8001                :::*                    LISTEN      797/sshd: root  

It is ready to listen on 8001.
To ping the vps_ip from other pc(not the previous local pc),shows that connection between pc is in good status.
Input http://vps_ip:8001 in other pc.

The connection was reset

The connection to the server was reset while the page was loading.

    The site could be temporarily unavailable or too busy. Try again in a few moments.
    If you are unable to load any pages, check your computer’s network connection.
    If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

Why can’t expose my local port publicly with ssh remote forwording via vps?

Go to Source
Author: it_is_a_literature