Get data from one url by using custom url pattern wp - wordpress

Can anybody suggest me this-
example.com/topic/a-1.html using this url i want to get data from
example.com/topic?page=a&number=1 in wp.
I tried wp rewrite functions but that could not helped me.
& I tried this too.
RewriteEngine On
RewriteRule ^([^/])/([^/]).html$ /topic?page=$1&num=$2 [L]
Thanks for your reply.

If you set permalinks in options, all links in your site will have the form site.com/page, but if you need delivery get parameter you can do it anyway, adding at the end of the get request site.com/page?id=1&page=2

Well finally i got this rule.
i was missing index.php thats why wp was redirecting to 404.
RewriteRule ^topic/([^/])/([^/])$ index.php/topic?page=$1&num=$2 [L]
Finally it worked for me. :)

Related

Redirect one image to webpage Issue

I hope everyone is well.
I am having a few issues trying to redirect an image that was linked in error from an email to a html page.
For example the email points here - https://www.caravanguard.co.uk/news/wp-content/uploads/2021/03/Swift-Vogue-580-1.jpeg
But should point here - https://www.caravanguard.co.uk/news/make-mine-a-dealer-special-caravan-25644/
I have appplied the following to our .htaccess, but it does not appear to have worked. I have also done the same in the wordpress yoast plugin we use.
redirect 301 /news/wp-content/uploads/2021/03/Swift-Vogue-580-1.jpeg /news/make-mine-a-dealer-special-caravan-25644/
Any ideas?
With your shown samples, could you please try following. Please make sure to place these rules at top of your .htaccess file. Also please do clear your browser cache before testing any URLs.
RewriteEngine ON
RewriteRule ^news/wp-content/uploads/2021/03/Swift-Vogue-580-1\.jpeg/?$ /news/make-mine-a-dealer-special-caravan-25644/ [R=301,NC,L]
You can use a RewriteRule
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/news/wp-content/uploads/2021/03/Swift-Vogue-580-1.jpeg$
RewriteRule ^.+$ /news/make-mine-a-dealer-special-caravan-25644/ [R=301]
Make sure this rule is at the top of your htaccess or before your WordPress rules.
Had to remove the image from wordpress before it would allow the redirect to work. WP rules seem to have got in the way. The .htaccess rule I originally created then kicked in.
I tried the above comments prior to the deletion and they did not work. Cheers for your help both.

URL rewriting with WordPress

I have WordPress running on Apache, I have some URL like this one:
https://www.mywebsite.com/fr/?type=Manager
And I want it to be :
https://www.mywebsite.com/fr/manager/
I tried different things such as:
RewriteRule ^?type=Manager$ manager/
but it's not working. With this one for example I'm getting a 500 error, and sometimes it just does nothing. I don't know if it's my htaccess config, or because it's WordPress or because I'm stupid.
Use this rule in your .htaccess instead:
RewriteRule ^fr/([^/]*)$ /fr/?type=$1 [L]
Make sure you clear your cache before testing this.

Wordpress Home page URL changing to /?i=1 - issue

When I try to access my Wordpress website directly or from google, the Home page URL automatically adding /?i=1 and sometimes /?i=2 to the URL in the address bar.
I think it's a very simple to solve it, but I tried many things and didn't work.
So I wonder how can I solve this to be only the URL without /?i=1 or /?i=2 ?
/?i=1 or /?i=2 protects your website from bots and is mostly applied by free hosting services and if you use any .htaccess code to remove it than all ? parameters will removed and redirect you to homepage
Try resetting your wordpress permalink from admin end. If you don't know how to do that check this video. As this is not normal behavior of wordpress you can also check your .htaccess file.
RewriteCond %{QUERY_STRING} ^(.*)i=[^&]+(.*)$ [NC]
RewriteRule ^(.*)$ /$1?%1%2 [R=301,L]
Add this in htaccess

Rewriting URL still redirects to old URL

I am trying to access
https://www.onlybrighton.com/optin-ninja/onlybrightona/
using
https://www.onlybrighton.com/jani
but it doesn't seem to be working right and it's redirecting me to
/onlybrightona/
URL when I enter
/jani
URL in browser
I am using follwing rule:
RewriteRule ^jani$ /optin-ninja/onlybrightona/ [QSA,L]
Apologies for being so blunt but I really am new into this.
Edit: in a nutshell my problem is .htaccess rule redirecting, but not rewriting
Can you please try it :
RewriteRule ^jani/?$ https://www.onlybrighton.com/optin-ninja/onlybrightona/ [R=301,NC,L]
Please try above code and let me know.

Symfony & mod_rewrite

Looking for some good skills in mod_rewrite or Symfony (not sure from where the problem comes!)
I was using mod_rewrite normal, but somehow, I can't get this to work. I mean, when requesting this url:
A- http://www.balancextreme.es/pulseras-y-zapatillas-famosos.html
should load:
B- http://www.balancextreme.es/tiendaweb/pulseras-y-zapatillas-famosos/culture/es.html
ok, but not as a redirect, I mean, the address bar must be showing the url A.
Url B, for itself, charges perfectly, and so far this is my mod_rewrite line:
RewriteRule ^pulseras-y-zapatillas-famosos\.html$ /tiendaweb/pulseras-y-zapatillas-famosos/culture/es.html [L]
that doesn't work :(
Hope some can give some tips! thanks!
In Symfony web directory have .htaccess file and you can add following code in first line. it's working for me. Hope this will solve your issue.
RewriteRule ^pulseras-y-zapatillas-famosos\.html$ /tiendaweb/pulseras-y-zapatillas-famosos/culture/es.html [L]

Resources