We use cookies to make your viewing experience better. By accepting you consent, you agree to our Cookie policy

Accept
Improve your Craft CMS skills

How To Set Your Site URL In Craft CMS

10 min read
How To Set Your Site URL In Craft CMS

Struggling with Craft CMS’s default site URL format? Custom domains enhance branding and provide SEO benefits. Changing your URL sounds simple but requires careful configuration of settings, rewrite rules, redirects, and search engine submission. This guide provides expert tips to properly set a new site URL in Craft CMS without disrupting performance. Follow our step-by-step process to seamlessly transition to an optimal custom domain.

To set a custom site URL in Craft CMS, login to the control panel, navigate to Settings > Sites, select your site, edit the Site URL field with your desired domain, save changes, enable URL rewriting in .htaccess, test navigation links, redirect traffic from old URL with 301s, verify new URL in search consoles like Google and Bing, and monitor site performance.

Accessing the Site URL Settings in the Craft CMS Control Panel

Locating the Site Settings in the Control Panel

To configure the site URL in Craft CMS, you'll first need to access the control panel. After logging in, navigate to Settings in the left sidebar menu. Next, click on Sites and select the specific site you want to edit from the list. This will open up the Site Settings page for that particular site.

On the Site Settings page, scroll down to find the Site URL field. This is where you can enter a custom URL for your site. The default URL will be something like example.test which is generated automatically when you create the site. To use a custom domain, you would enter it here in the Site URL field (e.g. www.yourdomain.com).

So in summary, accessing the site URL setting involves logging into the control panel, going to Settings > Sites > [Your Site] > Site Settings and then locating the Site URL field on that screen. With the right permissions, you can then edit this field to configure a custom domain.

Overview of Site Settings and Configuration

The Site Settings screen contains various configuration options for the selected site. At the top are fields for entering a Site Name, Handle and Site URL.

Further down you'll find additional settings such as Language, Base URL, Service Category, Enabled (to make the site live or offline) and some SEO fields. There's also Asset Storage configuration where you can define custom upload paths.

So in the context of configuring the site URL, it's simply a case of filling out that Site URL field with your desired domain name. The Base URL field also relates to this but normally you would just enter the URL path here (e.g. /) and handle the domain in the Site URL field.

This provides a nice central place to manage the core configuration details for any site created in Craft CMS. Having the ability to set a custom domain is very useful for launching a real production website.

User Permissions Required

In order to access the Site Settings and edit the Site URL, a user account needs the appropriate permissions. By default, admin accounts will have full access to everything in the control panel.

For other users, you need to grant their role permissions to the Sites section under Settings. The permission required to edit Site Settings is "Manage sites". Without this, users will be unable to view or update those fields.

So in summary, a user needs write access permissions for the Sites section in order to modify the Site URL setting. Regular editor accounts won't have access by default - you would need to create a custom role with "Manage sites" enabled under Sites permissions. This allows you to control who can setup and configure sites in your Craft CMS system.

Understanding Default URL Structure in Craft CMS

Index.php and Template Rendering

In Craft CMS, the index.php file plays a key role in rendering pages and defining URL structure. When a page request comes in, index.php is loaded first and handles parsing the URL, determining which Twig template to render, and passing data to that template.

The relationship between index.php and the URL is as follows - the URL path after the domain determines which template index.php will render. For example, if the URL is www.example.com/about, index.php will see the /about path and know to render the about Twig template.

So in summary, index.php receives the request, parses the URL to see which template should be rendered, fetches the appropriate data, and passes it to the Twig template to generate the HTML output displayed to the user. This is the default pattern for rendering pages in Craft CMS.

Craft Variables in Default URL

The default auto-generated URL in a fresh Craft CMS install generally uses two variables - SITE_URL and {siteName}.

SITE_URL defines the base URL for the site, usually in the format http://example.test where example is the {siteName} variable, populated with the site's name value from the control panel.

Together, SITE_URL concatenated with {siteName} forms the root URL for the site. So with a site name of mycompany, the default URL would be http://mycompany.test.

Additional URL segments like /about can be added after the {siteName} variable to define pages and templates, forming a URL such as http://mycompany.test/about.

So in summary, the default URL uses SITE_URL, {siteName} and routing strings like /about to determine which templates to render. This auto-generated URL is defined purely through Craft without needing a custom domain.

Example Default URL Formats

Here are some examples of common default Craft CMS URL formats:

So in summary, the default URLs contain the SITE_URL, {siteName}, template paths, and may also include index.php and subfolders depending on project configuration. These allow Craft to take a default URL and render the appropriate page without needing a custom domain.

Setting a Custom URL in Craft CMS

Benefits of a Custom URL

The default Craft CMS URL works well technically, but using a custom URL offers some nice benefits, especially for public-facing sites.

A custom URL helps with branding and memorability. mycompany.com is a lot more professional than a default mycompany.test URL. Custom domains look better to visitors and aid with brand recognition.

Brevity is another advantage - a short, punchy URL like craftcms.tips is preferable to a long default with multiple segments and variables.

Custom URLs also provide SEO benefits by allowing target keywords to be incorporated into the domain name itself. craftcms.tips optimize for "Craft CMS tips" better than a generic default URL.

So in summary, the main reasons to set a custom URL are branding, brevity, memorability for users, and search engine optimization. It gives a site a professional customized identity compared to the default auto-generated URL.

Choosing an Optimal URL

When selecting a custom URL, there are a few best practices to follow:

  • Make it short and punchy where possible. craftcms.help is better than learnhowtousecraftcms.com.

  • Incorporate target keywords if relevant, such as your brand name or topics.

  • Use hyphens to break up long phrases like craft-cms-guide.com.

  • Make it easy to say and remember.

  • Consider buying multiple domains (e.g. .com, .net, .co.uk) to control variations.

Some examples of well-structured custom URLs:

  • craftcms.guru

  • sitecraft.io

  • craft-tutorials.co.uk

  • mysite.agency

So in summary, choose something short, brandable, memorable, and keyword-relevant where possible. Check availability across multiple TLDs and buy multiple domains if you can.

Entering Custom URL in Control Panel

To set a custom URL in Craft CMS, follow these steps:

  1. Login to the control panel and navigate to Settings > Sites. Select your site.

  2. On the Site Settings page, locate the Site URL field and delete the default URL.

  3. Enter your new custom URL, such as www.mysite.com or mysite.co.uk.

  4. Click "Save Site" to save and apply your new URL.

Once saved, your custom domain should immediately take effect. Set up DNS and domain registration records to point your domain to the Craft CMS server.

So in summary, the process involves accessing the site settings, entering the desired URL in the site URL field, saving the site, and configuring DNS to point the domain to your server. Take advantage of custom URLs to brand your site and optimize for search engines.

Enabling URL Rewriting for the New URL

URL Rewriting in Craft CMS

When setting a custom URL in Craft CMS, URL rewriting needs to be enabled for the new domain name to work properly.

URL rewriting maps the custom URL to the corresponding page and templates in Craft. For example, rewriting rules will take www.mysite.com/about and point it to the about Twig template.

This happens through .htaccess files on Apache servers or Nginx configuration on Nginx servers. The rewrite rules match incoming URLs and rewrite them to the internal Craft URLs.

Without rewriting enabled, custom URLs would return errors or 404 pages, so it's a crucial step when changing the site URL. The rewrite rules translate the custom domain to work with the default Craft URL format and templates.

Enabling Rewrite Rules

To enable rewriting for a new URL in Craft CMS:

  • Verify the mod_rewrite Apache module is installed and enabled on your server.

  • Update the .htaccess file in your Craft project's web root folder with the proper rewrite rules and conditions (Craft includes samples).

  • Test that the rules are active by accessing your site with the custom URL - you should see it loading properly.

  • Adjust regex patterns and flags as needed if you get 500 errors or odd behavior.

  • Flush caches and restart services after making changes.

The key steps are installing mod_rewrite, adding the provided .htaccess rules, and tweaking them until requests to the custom domain are rewriting correctly.

Troubleshooting Rewrite Issues

Some common problems when setting up rewriting:

  • 500 Internal Server Error - Fix by adjusting regex in the .htaccess file or server config.

  • Page Not Found errors - Double check .htaccess rules cover all pages and templates.

  • Rewrite loops - Exclude already processed URIs from getting re-written.

  • Changes not applying - Flush caches and restart Apache/Nginx to load new config.

  • Incorrect pages loading - Adjust regex patterns to capture URLs correctly.

So in summary, fix rewrite problems by verifying server modules, carefully testing rule regex, adding exclusions, flushing caches regularly, and restarting services to load updates. With careful configuration, rewriting will enable the custom URL across all templates and pages.

Testing and Validating the New Site URL

Link and Navigation Testing

Thoroughly testing all site navigation and internal links is crucial after changing the URL to ensure everything functions smoothly. Start by methodically clicking through all top and footer menus, verifying that each link correctly loads the appropriate page or content item it points to. Pay particular attention to links in main site navigation elements, as these are typically accessed frequently by visitors.

Next, check that site search and any filters work properly, loading relevant results pages. Links on images, media assets, and other uploaded files should also be tested to confirm they open the correct resources. Form submission flows are another important element - validate that contact forms, sign up forms, and the like submit to their intended confirmation or thank you pages.

Inevitably, some links may break with the URL transition. Fix these promptly by updating the links to reflect the new URL structure. Comprehensive internal link validation is key to smooth site navigation.

External Validation

In addition to thorough internal testing, the new URL must be validated externally to ensure optimal functionality for visitors worldwide. Load speed tests using tools like Pingdom and GTmetrix will confirm site performance remains fast over the new domain. Verify proper crawlability in search engine tools, and check that key SEO plugins like sitemaps and robots.txt files are accessible at the new URL.

Accessing the site on various devices including mobile, tablets, and desktops validates responsiveness, while testing from multiple locations and networks will uncover any geography or provider-specific issues. Tweaking server configuration and testing again helps resolve such external accessibility problems. This global validation is essential for optimal visitor experiences.

Monitoring Site Traffic and Performance

Ongoing monitoring provides vital insights into real-world impact when a new URL is implemented. Watch Google Analytics reports for any notable changes in overall traffic volume, source breakdowns, site flow, and visitor behavior after the migration. Server performance should also be tracked - abrupt spikes or drops in site speed or response times may indicate configuration issues to address.

Analyze 404 errors for invalid links clicking through from external sites. Check site indexation in search engine tools like Search Console, and monitor rankings for target keywords to quickly spot significant gains or losses after the URL switch. The key is continuously monitoring performance and traffic data points to catch potential problems early and optimize ongoing SEO.

Redirecting Traffic from the Old URL

Using 301 Redirects

When transitioning to a new URL, it's important to redirect traffic from the old domain or site address. 301 permanent redirects are the best way to forward visitors and signals to the new URL.

301s can be implemented in Craft CMS via the .htaccess file, or using a plugin like Redirection or Safe Redirect Manager. The redirects should send all old URLs to their new counterparts while preserving URL parameters and structure.

For example:

Redirect 301 /oldpage.html https://newsite.com/newpage

Redirect 301 /category/posts https://newsite.com/blog

Properly configured 301s will forward all traffic and authority from the old URL, providing a smooth transition for visitors and search engines.

Redirect Considerations

Best practices for implementing 301 redirects include:

  • Preserve URL parameters and structure - don't just redirect homepages.

  • Maintain link equity - pass along authority and rankings.

  • Monitor redirect chains - avoid looping back and forth.

  • Match old URLs closely - consider variants and subfolders.

  • Use temporary 302s for testing before switching to 301s.

  • Don't redirect to broken pages - double check destination URLs.

The goal is to seamlessly bridge the old site architecture and URLs to the new domain with minimal disruption for users.

Tracking Redirect Performance

Use tools like Google Search Console to monitor redirect implementation:

  • Check coverage - are all old URLs redirecting properly?

  • Validate redirect status codes - should display 301s.

  • Watch for sudden drops in traffic that may indicate issues.

  • Fix any invalid or broken redirects immediately.

  • Clear caching and test again if problems persist.

Monitoring redirect performance ensures a smooth transition, with all old URLs forwarding perfectly to their new destinations. Quickly troubleshoot and fix any redirect errors or exceptions.

Submitting New URL to Search Engines

Google Search Console

Verifying the new URL in Google Search Console is a key step to maintain optimal visibility. Start by logging into your site's Search Console property and navigating to the Add Property flow.

Enter the new URL through Google's verification process using HTML tags or DNS records.

With the site verified under the new domain, submit this change of address in the Change of Address report. Specify that it is a permanent move and provide the old URL so Google can connect the performance history and signals from the previous domain.

After submission, check Index Coverage to ensure Google is detecting and crawling all URLs under the new domain. Use the submit URLs tool to request crawling for any pages not yet indexed. Also closely monitor impressions and click performance in Search Analytics to watch for any major fluctuations that may indicate issues to address.

Bing, Yandex, Baidu

Updating all other relevant search engines is also important when changing URLs. For Bing, verify the new URL in Bing Webmaster Tools, then submit it under Site Configuration. Yandex involves adding the new domain in Webmaster Tools and changing the address under Site Settings. For Baidu, verify through HTML tags or DNS and update the URL in their webmaster platform.

Don't forget about regional and country-specific engines like Naver for Korea and Seznam in Czechia. Verify and submit the new URL in each platform accordingly. Properly confirming the new domain across search engines ensures optimal crawling, indexing, and performance tracking.

Site Performance Monitoring

Closely monitoring key site performance reports in search tools provides valuable insights into how the URL change impacts visibility. Watch for fluctuations in impression volume and click-through-rates. Keep an eye on crawl stats to catch any dramatic increases or decreases.

Review index coverage reports frequently to check for potential holes or issues needing resolution.

It's also important to monitor search rankings in SERPs to quickly catch any gains or losses for key terms. Analyze user experience metrics like bounce rates as well to spot changes in visitor behavior. Address any technical SEO issues promptly as they arise. Ongoing monitoring and optimization ensures a smooth transition to the new URL.

Shape April 2022 HR 202
Andy Golpys
- Author

Andy has scaled multiple businesses and is a big believer in Craft CMS as a tool that benefits both Designer, Developer and Client. 

Share
Feedback
Show us some love
Email Us
We usually reply within 72 hours
Agency Directory
Submit your agency
Affiliate Partners
Let's chat