Compare commits
2
Commits
592d3071ed
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
689c1dd5a4 | ||
|
|
de975f7bc6 |
Regular → Executable
+26
@@ -1 +1,27 @@
|
|||||||
#! /usr/bin/python3
|
#! /usr/bin/python3
|
||||||
|
|
||||||
|
import csv
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
links = []
|
||||||
|
with open('links.csv') as csvfile:
|
||||||
|
dreader = csv.DictReader(csvfile)
|
||||||
|
for line in dreader: links.append(line)
|
||||||
|
|
||||||
|
# print(links)
|
||||||
|
|
||||||
|
oldDomain = urlparse(links[0]['Old Link']).netloc
|
||||||
|
newDomain = urlparse(links[0]['New Link']).netloc
|
||||||
|
htaccessText = f'### 301 redirection from {oldDomain} to {newDomain} ###\n'
|
||||||
|
|
||||||
|
for line in links:
|
||||||
|
old_path = urlparse(line['Old Link']).path
|
||||||
|
new_link = line['New Link']
|
||||||
|
htaccessText += f'Redirect 301 {old_path} {new_link}\n'
|
||||||
|
|
||||||
|
htaccessText += '\n\n'
|
||||||
|
print(htaccessText)
|
||||||
|
|
||||||
|
htaccess_file = open('htaccess.txt', 'a')
|
||||||
|
htaccess_file.write(htaccessText)
|
||||||
|
htaccess_file.close()
|
||||||
Reference in new issue
Block a user