.htaccess regex beginner redirection problem - wordpress

I'm a beginner in redirecting with htaccess. I wanted to do a small redirect, but am already stuck.
My first redirect was:
RewriteRule ^/project/(.*) /search/?type=details&projectid=$1 [R=301,L]
Which works fine. The problem is, that if the link gets shared on facebook, the outbound link of facebook is added with a ?fbclid=XXX. So my links get turned into:
/search/?type=details&projectid=1?fbclid=XXX
So now I somehow have to find the "?fbclid=XXX" (in case there is one) and stick it behind a &. For now I have:
RewriteRule ^/project/([^/]*)/?(.*)$ /search/?type=details&projectid=$1&$2 [R=301,L]
But this only works if there is a / inbetween the projectid and ?fbclid.
Can anyone give me a clue, what I'm missing?
thank you very much.

Related

Weird Domain handling for Wordpress

I have a really weird issue. My customer wants to have a website structure that ist like the following:
www.mydomain.com/myapplication/de/
www.mydomain.com/myapplication/at/
www.mydomain.com/myapplication/ch/
They have installed Wordpress to the /de/ folder.
Now they want to also reach the same wordpress-installation by going to /at/ and /ch/ but keeping this URL-Fomat.
so
www.mydomain.com/myapplication/de/a-wordpress-page.php
should also be reachable like:
www.mydomain.com/myapplication/at/a-wordpress-page.php
www.mydomain.com/myapplication/ch/a-wordpress-page.php
Unfortunately putting the wordpress-application to the maindomain is not an option, due to their weird system...
I hope is understandable.
Hope someone can help me.
It's easy.
You can redirect or rewrite your /myapplication/at/ and /myapplication/ch/ URL paths to the main /myapplication/de/ using a RewriteRule in htaccess.
RewriteEngine on
RewriteRule ^myapplication/(at|ch)/(.*)$ /myapplication/de/$2 [L,R]
Put this at the top of your WordPress htaccess file.
And change R to R=301 when you are sure the redirection is working perfectly fine.
If you want to keep the URL format then just remove the R flag from the rule. The rule with R will make an invisible redirection of URLs.

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.

wordpress based website - redirection to https + www working fine except in IE

I am currently trying to write redirect rules for my website but I am afraid I got stuck. I was wondering if anyone experienced a similar issue before and maybe would a a quick fix for me.
I am trying to redirect my user from:
domain
www.domain
http://domain
https://domain
http://www.domain
to a single
https://www.domain website.
So basically I want to force https connections and add the www in each case.
I am using the code below in the .htaccess file, and it seems to be working fine in chrome and firefox, but IE(11) does not seem to process it.
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://www.%{SERVER_NAME}/$1 [R,L]
Is there any inherent reason why IE cannot process it? If you have any tips or suggestion, I am all ears :)
Thanks in advance.

Redirect slug, replace plus for dashes

I have a rewrite question. It drives me crazy. I created a new website in worpdress. I want to redirect old urls (that are in google) to the new urls. That works fine except for the following urls (there is a plus in the old url)
www.domain.com/slugname/this+is+a+slug
Has to be rewritten to:
www.domain.com/slugname/this-is-a-slug
How to replace the plus for a dash (.htacces? add_rewrite_rule?)
Sombody has example code?
I tried .htacces an add_rewrite_rule in worpdress, but im not smart enough ;)
If you're happy to do it on an individual basis per URL then the following in your .htaccess file (it's important the file is spelt correctly) should work:
RewriteRule ^oldpage$ http://www.example.org/newpage? [R=301,L]
So your example might be:
RewriteRule ^slugname/this+is+a+slug$ http://www.example.org/slugname/this-is-a-slug? [R=301,L]
The R=301 part of the rule makes the redirect permanent, which I assume is the desired effect. Removing this would make the redirect a 302, which is known as temporary.
If you are looking to replace all + with - in the URL then you can use a generic statement:
RewriteRule ^(.*)+(.*)$ /$1-$2 [L,R=301]
There is a plugin in WordPress called Redirection, that will allow you to redirect old links to new links. It takes a lot of hassle from trying to do it in the .htaccess. You can use regex on the plugin.
Once installed the plugin can be found under the tools menu.

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