I have lot of URL links that looks like:
https://www.example.com/category/product_name?product_rewrite=product_name
I am trying to redirect them to:
https://www.example.com/category/product_name
I have a module in Prestashop where I can put regex for redirect old to new URL.
I am trying with:
OLD URL: https://www.example.com/(.)\?product_rewrite=(.)
New URL: https://www.exampe.com/(.*)\
Unfortunately above is not working and can not find why - because module is not working properly or because I am giving wrong data.
Related
I am trying to change the permalink structure of my Wordpress site and setting up proper redirects. Here is what I am trying to achieve:
Old permalink structure:
/category/post-name
New permalink structure:
/postname
Redirecting would be fairly simply done by:
Source:
/category/(.*)
Destination:
/$1
However, the base URL without the post-name must not be rewritten. So if someone access /category directly (without specifying a post-name) it should not redirect, because /category is a valid page. It should only redirect if something is following /category.
Example:
https://somesite.com/category -> Don't redirect
https://somesite.com/category/post-123 -> redirect URL to https://somesite.com/post-123
Any ideas how I can do this? Note: I am using the Yoast Plugin and its RegEx redirect option.
I am not a coder, so sorry for my gibberish. I hope I am making some sense.
Thank you! :)
Use .+ to match at least one character:
/category/(.+)
I'm re-working a Woocommerce store, and I need to set up redirects that will send the old URLs, which include category names, to the new URLs, which won't.
EDIT: Both the old and new URLs will contain product/ and the old URL may or may not have a trailing slash.
An example would be:
Old URL: myshop.co.uk/product/category-name/sub-category-name/product-name
New URL: myshop.co.uk/product/product-name
Can anyone tell me what the reg exp would be to achieve this?
Search for (?<=product/)(?:[^/]+/)+(?=[^/]+/?$) and replace with an empty string.
I need to make some redirections in a wordpress site with "Redirections" plugin that allows only regex. Exactly i need to transform this url model:
http://example.com/cat1/subcat2/subcat3/subcat4/bar/this%20is%20page?start=130
To:
http://example.com/bar/this-is-page
Only if "bar" is in url. Anyway, last segment can be like this /page.
How can i obtain that result?
I am trying to have new redirect rules using regex, and need to reuse some of the data in the new URL format.
Old URL structure:
http://www.example.com/shop/checkout/order-received/DATA1?key=DATA2
NEW URL Structure:
http://www.example.com/?page_id=12874&order-received=DATA1&key=DATA2
How should I do that?
Thanks!
I am using new Django 1.8 app to learn Django.
I am stumped as to how to get this my simple url to be resolved by urls.py
I create the url in another view as:
<a href="/photoview/{{photo.id}}/"}>
I can successfully pass this url to the browser as:
http://localhost:8000/photoview/300/
I am expecting that this url can be matched by the urls.py expression:
url('r^photoview/(?P<id>\d+)/$', views.photoview),
But this is not working. I have tried variations of this but none have worked so far, such as:
url('r^photoview/(?P<id>[0-9]+)/$', views.photoview),
I get this message in browser when it fails to match
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/photoview/300/
Using the URLconf defined in asset.urls, Django tried these URL patterns, in this order:
^admin/
^$ [name='index']
^time/$
^about/$
^accounts/$
^photos/$
^tags/$
^users/$
r^photoview/(?P<id>\d+)/$
^static\/photos\/(?P<path>.*)$
The current URL, photoview/300/, didn't match any of these.
Appreciate any help getting this to work.
you have url('r^photoview/(?P<id>\d+)/$', views.photoview),
you want url(r'^photoview/(?P<id>\d+)/$', views.photoview),
(Note the r is in front of the string, not the first character)
As noted in docs.djangoproject.com/en/1.8/topics/http/urls,
The 'r' in front of each regular expression string is optional but
recommended. It tells Python that a string is “raw” – that nothing in
the string should be escaped
Also note that you should use a friendly name in your url definition (e.g. photoview) and then use {% url 'photoview' photo.id %} in your template instead of hardcoding the URL pattern.