Examples of using regular expressions in Archivarix CMS

Published: 2020-05-29

How to generate meta name="description" on all pages of a website? How to make the site work not from the root, but from a subdirectory?

Sometimes it happens that on some pages of the restored site there is no meta name="description" tag. It can be added manually, but if it is not available on hundreds or thousands of pages, then it will be difficult to do. In order not to think about compiling page descriptions for a long time, you can simply put in this tag the first phrase that appears in the text on this page. Usually it will be relevant.

The opportunity to use regular expressions for searching and replacing in Archivarix CMS may help you with it. Simply copy the following regular expression into the appropriate fields in the Search and Replace tool and start the process.

(</title>)(.*?<p>([^"<]{50,200}\.))

 

$1
<meta name="description" content="$3">
$2

 

meta name="description" 

 

This regular expression creates the <meta name = "description" content = tag immediately after the closing </title>  and adds text from the page starting with the paragraph tag <p> and having a minimum of 20 characters and a maximum of 200 characters and closes the tag with a dot . The filter rule makes replacements only on those pages where there is no meta name = "description" .

 

Another example: A restored site can be redone so that it can work from a subdirectory. This may be necessary if you need to host several restored websites on the same domain. 

To begin with, we change all the paths in the site structure by using the Search and Replace URL tool . 

To all URLs from the beginning ^ we add a new path /newsite1

Next, we replace all the addresses inside the pages using regular expressions, be sure to include all the files (js, css, txt, json, xml) in the request:

\b((?:href|src)=['"]?)(/[^/])

$1/newsite1$2

To fix links to images in CSS files, you can use the following regular expression:

(url \ (['"\ s]) (/ [^ /])

Now in the .htaccess file you need to replace the line RewriteRule. /index.php [L] on such a line - RewriteRule. /newsite1/index.php [L]

Your website will work now at domain.com/newsite1

The use of article materials is allowed only if the link to the source is posted: https://archivarix.com/en/blog/regex-add-description-website-on-subfolder/

BLACKFRIDAY

Two big tasty coupons are valid from Friday 27.11.2020 to Monday 30.11.2020. Each of them gives a balance bonus in the form of 20% or 50% of the amount of your last or new payment.…

5 days ago
Happy 3rd birthday to Archivarix

Three years ago, on September 29, 2017, our archive.org downloader service was launched. All these 3 years we have been continuously developing, we have created our own CMS, a Wordpress plugin, a syst…

2 months ago
Archivarix.net - Web archive and search engine.

Wayback Machine ( web.archive.org ) Alternative. Internet archive search engine. Find archived copies of websites. Data from 1996. Full-text search.
In the near future, our team plans to launch a uni…

2 months ago
Examples of using regular expressions in Archivarix CMS

How to generate meta name="description" on all pages of a website? How to make the site work not from the root, but from a subdirectory?…

6 months ago
How to show hidden files on macOS.

How to show hidden files on macOS. How to view and edit files starting with dot ( like .htaccess ) in macOS?…

7 months ago
Website downloader. How to choose the files limit?

Our Website downloader system allows you to download up to 200 files from a website for free. If there are more files on the site and you need all of them, then you can pay for this service. Download …

9 months ago
Regular expressions used in Archivarix CMS

This article describes regular expressions used to search and replace content in websites restored using the Archivarix System. They are not unique to this system. If you know the regular expressions …

10 months ago
Simple and compact Archivarix CMS. Flat-file CMS for downloaded websites.

In order to make it convenient for you to edit the websites restored in our system, we have developed a simple Flat File CMS consisting of just one small php file. Despite its size, this CMS is a powe…

10 months ago
Best Wayback Machine alternatives. How to find deleted websites.

The Wayback Machine is the famous and biggest archive of websites in the world. It has more than 400 billion pages on their servers. Is there any archiving services like Archive.org? …

10 months ago
How to download an entire website from Google Cache?

If the website was recently deleted, but the Wayback Machine didn't save the latest version, what you can do to get the content? Google Cache will help you to do this. All you need is to install this …

11 months ago
Latest news:
2020.11.03
The new version of CMS has become more convenient and understandable for webmasters from around the world.

- Full localization of Archivarix CMS into 13 languages (English, Spanish, Italian, German, French, Portuguese, Polish, Turkish, Japanese, Chinese, Russian, Ukrainian, Belarusian).
- Export all current site data to a zip archive to save a backup or transfer to another site.
- Show and remove broken zip archives in import tools.
- PHP version check during installation.
- Information for installing CMS on a server with NGINX + PHP-FPM.
- In the search, when the expert mode is on, the date/time of the page and a link to its copy in the WebArchive are displayed.
- Improvements to the user interface.
- Code optimization.

If you are a native speaker of a language into which our CMS has not yet been translated, then we invite you to make our product even better. Via Crowdin service you can apply and become our official translator into new languages.
2020.10.06
A new Archivarix CMS version.
- CLI support to deploy websites right from a command line, imports, settings, stats, history purge and system update.
- Support for password_hash() encrypted passwords that can be used in CLI.
- Expert mode to enable an additional debug information, experimental tools and direct links to WebArchive saved snapshots.
- Tools for broken internal images and links can now return a list of all missing urls instead of deleting.
- Import tool shows corrupted/incomplete zip files that can be removed.
- Improved cookie support to catch up with requirements of modern browsers.
- A setting to select default editor to HTML pages (visual editor or code).
- Changes tab showing text differences is off by default, can be turned on in settings.
- You can roll back to a specific change in the Changes tab.
- Fixed XML sitemap url for websites that are built with a www subdomain.
- Fixed removal temporary files that were created during an installation/import process.
- Faster history purge.
- Femoved unused localization phrases.
- Language switch on the login screen.
- Updated external packages to their most recent versions.
- Optimized memory usage for calculating text differences in the Changes tab.
- Improved support for old versions of php-dom extension.
- An experimental tool to fix file sizes in the database in case you edited files directly on a server.
- An experimental and very raw flat-structure export tool.
- An experimental public key support for the future API features.
2020.06.08
The first June update of Archivarix CMS with new, convenient features.
- Fixed: History section did not work when there was no zip extension enabled in php.
- New History tab with details of changes when editing text files.
- .htaccess edit tool.
- Ability to clean up backups to the desired rollback point.
- "Missing URLs" section removed from Tools as it is accessible from the dashboard.
- Monitoring and showing free disk space in the dashboard.
- Improved check of the required PHP extensions on startup and initial installation.
- Minor cosmetic changes.
- All external tools updated to latest versions.
2020.05.21
An update that web studios and those using outsourcing will appreciate.
- Separate password for safe mode.
- Extended safe mode. Now you can create custom rules and files, but without executable code.
- Reinstalling the site from the CMS without having to manually delete anything from the server.
- Ability to sort custom rules.
- Improved Search & Replace for very large sites.
- Additional settings for the "Viewport meta tag" tool.
- Support for IDN domains on hosting with the old version of ICU.
- In the initial installation with a password, the ability to log out is added.
- If .htaccess is detected during integration with WP, then the Archivarix rules will be added to its beginning.
- When downloading sites by serial number, CDN is used to increase speed.
- Other minor improvements and fixes.
2020.05.12
Our Archivarix CMS is developing by leaps and bounds. The new update, in which the following appeared:
- New dashboard for viewing statistics, server settings and system updates.
- Ability to create templates and conveniently add new pages to the site.
- Integration with Wordpress and Joomla in one click.
- Now in Search & Replace, additional filtering is done in the form of a constructor, where you can add any number of rules.
- Now you can filter the results by domain/subdomains, date-time, file size.
- A new tool to reset the cache in Cloudlfare or enable / disable Dev Mode.
- A new tool for removing versioning in urls, for example, "?ver=1.2.3" in css or js. Allows you to repair even those pages that looked crooked in the WebArchive due to the lack of styles with different versions.
- The robots.txt tool has the ability to immediately enable and add a Sitemap map.
- Automatic and manual creation of rollback points for changes.
- Import can import templates.
- Saving/Importing settings of the loader contains the created custom files.
- For all actions that can last longer than a timeout, a progress bar is displayed.
- A tool to add a viewport meta tag to all pages of a site.
- Tools for removing broken links and images have the ability to account for files on the server.
- A new tool to fix incorrect urlencode links in html code. Rarely, but may come in handy.
- Improved missing urls tool. Together with the new loader, now counts calls to non-existent URLs.
- Regex Tips in Search & Replace.
- Improved checking for missing php extensions.
- Updated all used js tools to the latest versions.

This and many other cosmetic improvements and speed optimizations.