my mistake caused bad links on SE howto resolve it? - .htaccess

I made mistake in .htaccess on my site with following codes :
RewriteRule ^articles/isfahan_articles([0-9]+).html$ ./maghalat.php?id=$1
That it seems it have changed my links on Google and other search engines from:
siteaddress/articles/isfahan_articlesXXX.html
to :
siteaddress/maghalat.php/isfahan_articles108.html?id=108
how can I change my links on SE to old style:
siteaddress/articles/isfahan_articlesXXX.html
Note: I have changed my .htaccess to :
RewriteRule ^articles/isfahan_articles([0-9]+).html$ maghalat.php?id=$1
But my issue is still exist.

Google doesn't have a live version of your website - it visits it periodically and stores the results. So it will take a few days after you revert your URLs before they will be updated in google.
You can speed this up by submitting a Sitemap or increasing the Crawl Speed at:
https://www.google.com/webmasters/tools/

Related

How to redirect a URL?

I have a problem in redirecting a URL on a Silverstripe website. I have a news feed page with a summary of articles in a paginated style. It displays 20 articles initially and switches to the next 20 based on the page number chosen. It is just the standard blog layout. When I click on page 2 then it should navigate to https://*****/news/?count=20 and for page 3 as https://*****/news/?count=40 etc. However upon clicking the blog page number it navigates to https://*****/news/news/?count=20. So the navigation link is not rewriting the parent URL.
All of my other Silverstripe websites work fine with the same blog layout except this and I don't see any reason to tweak the default code. I thought of adding a .htaccess redirect like this
Redirect 301 /news/news/?start=20 https://******/news/?start=20
but I didn't have any luck to make it work. Kindly suggest me a solution for this.
The output I expect is to redirect to the right URL
https://******/news/?start=20
Here is a simple redirection rule that should fix the symptom you describe:
RewriteEngine on
RewriteRule ^/?news/news/(.*)$ /news/$1 [R=301,L]
But I doubt that approach is a good idea. Simply because it tries to fix a symptom, not the cause. The cause is that you actually create requests to URLs that contain the /news/news/ issue which should never happen. I assume the cause of that issue is that you hand out relative references (so something like news/...) instead of absolute references (/news/...). I strongly suggest that you handle the cause instead of trying to fix the symptom.

How to remove (not hide) a subdirectory from a URL using .htacesss

I have a series of URLs on my website:
http://www.example.com/sub1/sub2/content.html
But I would like to remove "sub1" completely - not hide it so it still attempts to access that directory. Finished result would be this URL:
http://www.example.com/sub2/content.html
Many similar posts on SE seem to demonstrate how to "hide" a URL from the user. I want to rewrite the URL so that it treats it as if it isn't even there.
Example of what I'm trying not to do: Hide Part of URL htaccess
NOTE: I do not want to actually delete files as suggested by the comment below. I'm trying to redirect the request to another directory.
This worked for me:
RewriteRule ^sub1/sub2/(.*)$ /sub2/$1 [R=302,NC,L]
Helpful page: http://coolestguidesontheplanet.com/redirecting-a-web-folder-directory-to-another-in-htaccess/

htaccess to remove print.html from url

We are currently hosting a large joomla site.
Google has indexed hundreds of the "print" versions of our pages.
for example if we have an article with the url:
www.mysite.com/funnyarticle.html
the joomla site automatically created:
www.mysite.com/funnyarticle/print.html
We have moved the site and deleted these pages, so they now get a 404 error from google.
We would like to redirect or rewrite (not sure what is the correct terminology) the "print" urls to their respective articles.
I would like to use htaccess to remove:
/print.html
and replace it with:
.html
I have seen examples but cannot get them to work correctly.
So I was hoping I could get specific advise on how to remove and replace the exact code above.
Thanks for your time.
Regards,
Aforantman
You can create a robot.txt file with following lines.
User-agent: *
Disallow: /*/print.html
this will disallow search engine robots to access files with name print.html.
You probably want to use a RewriteRule. See Apache's guide on how to use them: http://httpd.apache.org/docs/2.0/rewrite/rewrite_guide.html
But if you just want Google (and other search engines) to ignore those print versions, put a corresponding entry in you robots.txt. That way you don't need to fiddle around with Joomla's way of generating and accessing the print version for your human visitors.
You need to put these lines in your DOCROOT/.htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule ^(.*?)/print.html $1.html [L,R=301]
This will redirect any Google user clicking through to one of these pages to the correct article. If your article names can contain / then remove the ? from the above; the rule will still work but might take a few more μS runtime :-)
You can use robots.txt as said by Jishnu.This is the best way to do this.
User-agent: *
Disallow: /*/print.html

Google Campaign & Analytics URLs with .htaccess

One of our clients is launching a campaign around our city and one of the requirements they want is to track from what item a visitor has scanned in a QR code. To achieve this I have entered this into my .htaccess file:
RewriteRule ^(beermat|poster|flyer)$ /video?utm_source=$1&utm_medium=PrintedMaterial&utm_campaign=VideoCampaign2012 [R=301]
So if anyone scans in the QR code that has the address: http://www.website.com/beermat it redirects to /video with the relevant attributes.
If I have the google analytics code on the /video page this should work, correct?
Try this plugin to see if google-analytics is recording anything.
This way you can see directly if it is working or not.
https://chrome.google.com/webstore/detail/jnkmfdileelhofjcijamephohjechhna
I think it would be better for you to make "poster" a directory, and the index.php inside it should set $_SESSION['found']="poster" then redirect to the main page which would read from the SESSION.
The added benefit is that you're not left with any ugly GET data, just a nice clean url, but the downside is that you have to manually create the directories, so only do this if you have a manageable amount.

mod_rewrite caused drop my ranking

I'm owner of http://myisfahan.com. I have an article management system there that developed by myself.
Recently I changed article links from myisfahan.com/articles/isfahan_articleXXX.html to myisfahan.com/XXX_[article subject].html in newer version. Many of my articles had high ranking on Google (in Persian language).
Because I didn't know redirect older links to newer one I only wrote 2 instruction only in the .htaccess:
RewriteRule ^([0-9]+)_([^/\.]+).html$ maghalat.php?id=$1
RewriteRule ^articles/isfahan_articles([0-9]+).html$ maghalat.php?id=$1
After this major change Google.com dropped many of my page rankings and recently I have only 20% of normal site visitors.
My questions are:
Does this changes caused this drop of ranking, because in fact now I have 2 links for every content .
I fetch subject text by PHP and generate XXX_[article subject].html, how can I write a rewrite syntax that redirect isfahan_articlesXXX.html to XXX_[article subject].html file when XXX is article's ID in .htaccess file?
You should have 301 redirected your old links to your new links, after creating your new links.
If you did not or are duplicating links to the same content, this would indeed hurt your rankings.
UPDATE
Looks like you already have the RewriteRules in place that you need. Just add the following flags (note the 301 redirect for the old links) and over time it should (over time) rebuild your page rank.
RewriteRule ^([0-9]+)_([^/\.]+).html$ maghalat.php?id=$1 [L]
RewriteRule ^articles/isfahan_articles([0-9]+).html$ maghalat.php?id=$1 [R=301,L]

Resources