I've searched answers on the forum but didn't worked for me.
I have rebuild an website using Wordpress and want to keep old urls.
I have old URLs like : index.php?option=com_content&view=article&id=51&Itemid=67&lang=fr
that i want to move permanantly to url like : /produits-et-services/conseil-et-accompagnement/
Redirect 301 didn't worked because of vars in URL.. and i've try this :
RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=51&Itemid=67&lang=fr$ [NC]
RewriteRule ^index.php$ http://solunea.fr/produits-et-services/conseil-et-accompagnement/ [L,R=301]
On my wordpress .htaccess but didn't worked either.
Can someone help me please ??
Make sure this rule:
RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=51&Itemid=67&lang=fr$ [NC]
RewriteRule ^(index\.php)?$ /produits-et-services/conseil-et-accompagnement/ [L,R=301,NC]
is placed right on top before any other existing rewrite rule
and test in a different browser to avoid 301 caching issues.
Related
I'm having trouble redirecting a multilingual website one page. My redirection to htaccess doesn't operate properly. I need assistance with how this can be done. In my htaccess, when I add these two lines
RewriteCond %{QUERY_STRING} ^lang=en$
RewriteRule ^ /en? [R=301,L]
redirect working, but mysite.com/en show 404 not found. Someone help me with this?
Your redirect rule as shown in question is working fine. Bot you also need a rewrite rule to handle /en:
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^lang=([a-z]{2})$
RewriteRule ^ /%1? [R=301,L]
RewriteRule ^([a-z]{2})/?$ ?lang=$1 [QSA,L]
If your browsers ends up at mysite.com/en, your redirection does work, so your question is not how to redirect, but why there's no content at /en on your site. You need to investigate that.
At my website one page is no more existed but its URL is being used in some other websites, so can i redirect that old URL to my newly created URL.
I have tried the bellow rule but did not work
redirect 301 https://example.com/old.php https://example.com/new-page
Can anyone help?
Thanks in advance
Simplest way would be this:
Redirect 301 /oldsite.php https://example.com/new-page
some guide for you htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^site\.com$
RewriteRule (.*) http://www.sitename.com/$1 [R=301,L]
RewriteRule ^$ store [L]
I have an issue writing some regex to go inside my htaccess file.
Basically, my site has been setup so that index.php and all other site files are not in the root (public_html) directory but instead are in http://fitnessquiz.co.uk/fitnessquiz.co.uk/
Initially I tried the following in my public_html folder:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^fitnessquiz.co.uk$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.fitnessquiz.co.uk$
RewriteCond %{REQUEST_URI} !fitnessquiz.co.uk/
RewriteRule (.*) /fitnessquiz.co.uk/$1 [L]
which correctly navigates to my homepage and displays the url correctly but then when I click any link I get a "no input file specified" message. So then I tried replacing with:
RewriteCond %{REQUEST_URI} !^/fitnessquiz.co.uk/
RewriteRule ^(.*)$ /fitnessquiz.co.uk/$1 [L,R=301]
After which the site works but every url looks like this:
http://fitnessquiz.co.uk/fitnessquiz.co.uk/someotherfolder/etc.php
I've tried various htaccess regex solutions listed elsewhere on here but none seem to work, how do I accomplish both of these things i.e. redirect to /fitnessquiz.co.uk for every url but hide the duplicate url name/folder. Im on a shared server so don't have permissions to change any server/apache settings directly.
According to this answer by nuked on a previous post you could try:
RewriteCond %{THE_REQUEST} ^GET\ /fitnessquiz.co.uk/
RewriteCond %{HTTP_HOST} ^(www\.)?fitnessquiz.co.uk$
RewriteRule ^fitnessquiz.co.uk/(.*) /$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?fitnessquiz.co.uk$
RewriteRule !^fitnessquiz.co.uk/ fitnessquiz.co.uk%{REQUEST_URI} [L]
This set of rules worked for me on a very similar situation. I had employed the same cure, (re-direct if calling the folder and hide after re-writing it) but I never got the order right on my own. Thus I kept seeing the page not found errors too. Below is my attempt to explain the actions, for my own learning, hopefully others too.
RewriteCond %{THE_REQUEST} ^GET\ /fitnessquiz.co.uk/
Is asking the question, does THE_REQUEST contain the subfolder you need to hide?
RewriteCond %{HTTP_HOST} ^(www\.)?fitnessquiz.co.uk$
Checks if the request is for the correct host.
RewriteRule ^fitnessquiz.co.uk/(.*) /$1 [L,R=301]
Rewrite the URL as one without the subfolder and call the new link in the redirected browser. Note:
L : Last step. Stop processing other rules
R=301 : After re-writing, redirect the browser to the new URL.
When the page is redirected it has no subfolder so the first RewriteRule is skipped. And then
RewriteCond %{HTTP_HOST} ^(www\.)?fitnessquiz.co.uk$
checks if calling the right host. And then
RewriteRule !^fitnessquiz.co.uk/ fitnessquiz.co.uk%{REQUEST_URI} [L]
rewrites the url that has not the subfolder to use the correct subfolder without redirecting the page, and while hiding actual subfolder from the browser. Again note:
L : Last step. Stop processing other rules
I have already set yes for 'Web Server Rewrites' at System->Configuration->Web->Search Engine Optimization for my Magento site. It's working for SEO friendly urls fine without index.php in url, but if URL entered manually with index.php then it does not redirect the URL removing the index.php and for this I added these 2 lines in .htaccess files as:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index.php(/[^\s\?]+)? [NC]
RewriteRule ^ %1/ [L,R=301]`
And after this it removes the index.php from manually entered URLs as well. So, this issue get solved.
But now I am facing the issue in back-end. I am not able to expand the category and some time I am not able to login in admin.
Please suggest solution ASAP.
I got this solution and I put the code below in .htaccess and got resolved my issue.
RewriteRule ^(.*)(index.php/admin)($|/) - [L]
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.example.com/$1 [R=301,L]
RewriteRule ^index.php/(.*) $1 [R=301,QSA,L]
I was about to convert my webpage url into seo friendly. My url link is like follows
http://example.com/display.php?id=***
Now i want to convert this into seo friendly url, which could be
http://example.com/partners-id-***.html
Something like above. I used
RewriteEngine On
RewriteRule ^partners-id-([^-]*)\.html$ /display.php?id=$1 [L]
Rewrite rule in htaccess file. But still the url stays same as older one. Anyone can help me to fix this issue???
You need 1 more 301 rule before this rule for external redirection:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+display\.php\?id=([^\s&]+) [NC]
RewriteRule ^ /partners-id-%1.html? [R=301,L]
RewriteRule ^partners-id-([^.]*)\.html$ /display.php?id=$1 [L,QSA]
As commented by Justin and other folks it is better to change your links to /partners-id-123.html. However for links already cached by search engines will be taken care by first rule here which will 301 redirect:
/display.php?id=1234 => /partners-id-1234.html
Please try like below:
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /display.php?id=$1 [L]