Can I edit .htaccess file or does Shopify offer another way to do URL-Rewriting?

Solved
Highlighted
Excursionist
28 3 3

Hi all,

 

I have got a theme that allows filtering on a website and it filters using the URL which is:

"/collections/[collection]?constraint=[Tag]"

 

I would like to rewrite the URL so it looks more user friendly. like "/collections/[collection]/[tag]"

Does Shopify allow me to edit the .htaccess file to do this? if so how?

Does Shopify do this in a different way? if so how?

 

If neither of the above are options what are some alternatives?

 

Cheers,

Cyrius

1 Like
Highlighted
Pathfinder
103 4 11

@CyriusMedia wrote:

Hi all,

 

I have got a theme that allows filtering on a website and it filters using the URL which is:

"/collections/[collection]?constraint=[Tag]"

 

I would like to rewrite the URL so it looks more user friendly. like "/collections/[collection]/[tag]"

Does Shopify allow me to edit the .htaccess file to do this? if so how?

Does Shopify do this in a different way? if so how?

 

If neither of the above are options what are some alternatives?

 

Cheers,

Cyrius


As I see from Shopify document the default as your expected not your current version. You can see here: https://help.shopify.com/en/themes/customization/collections/filter-collections-with-product-tags

Vince Nguyen | Ecommerce Consultant at HappyPoints.io
Was my reply helpful? Click Like to let me know!
Was your question answered? Mark it as an Accepted Solution
Email me at: vince@happypoints.io
Skype: vince@happypoints.io
0 Likes
Highlighted
Excursionist
28 3 3

This doesn't answer the question. This shows me another way to filter.

I cannot change the way I am currently filtering since this is how the theme works and I don't want to redesign it (Mainly so that I don't have to re-fix it every time the theme updates). I have reworded my questions to avoid confusion.

 

Does Shopify allow me to edit the .htaccess file to dURL rewrite? if so how?

Does Shopify do URL rewriting in a different way? if so how?

1 Like
Highlighted
New Member
2 1 1

Hey @CyriusMedia -- we had a similar issue, wanted to provide a cleaner URL less the /pages/ path...

 

This isn't the most elegant solution but works like a charm, just drop this <script> tag on the first line of your 404.liquid template.

 

<script>
	if (window.location.pathname == "/demo"){
		location.replace(window.location.pathname.replace("/demo", "/pages/how-it-works"));
	}
</script>

 

NOTE: you'll need to replace the conditional path and the redirect target path respectfully with your own, but this should do the trick.

1 Like
Highlighted
New Member
2 0 0

@CyriusMedia I'm pretty sure this didn't answer your question either. If you did find a solution/answer regarding editing our shopify .htaccess file please update us if you would. Their are plenty more shop owners that are interested in being able to locate and edit this file also. Thank you.  @VacHack CyriusMedia wants to know how to edit their websites .htaccess file and where to locate it. 

0 Likes
Highlighted
Excursionist
28 3 3

It didn't answer my question. However it offered a solution to those who want to achieve this in another way.

 

From what I could find there is no way to do what I wanted.

This is because Shopify is already using the .htaccess to make the site work and don't want people changing this.

 

If anyone knows any different please correct me.

0 Likes
Highlighted

Success.

New Member
2 1 1

Perhaps this answers the question for you definitively:

 

You don't have access and cannot modify the .htaccess file with shopify.

0 Likes
Highlighted
New Member
1 0 0

@VacHack wrote:

Hey @CyriusMedia -- we had a similar issue, wanted to provide a cleaner URL less the /pages/ path...

 

This isn't the most elegant solution but works like a charm, just drop this <script> tag on the first line of your 404.liquid template.

 

<script>
	if (window.location.pathname == "/demo"){
		location.replace(window.location.pathname.replace("/demo", "/pages/how-it-works"));
	}
</script>

 

NOTE: you'll need to replace the conditional path and the redirect target path respectfully with your own, but this should do the trick.


This worked perfectly for me. Thanks

0 Likes