Remove special word from end of URLs with htaccess? - .htaccess

Google has founded 7500 Not Found 404 Error and I found out that almost all of them happened because of a button with "YourDrible" in href (only this word in url field) and all pages has this button so there are 7 k pages with this url pattern:
http://Some-True-URL/YourDribble
is there any way that I can put in htaccess or somewhere tell that every URL with "/YourDribble" at end should redirect to URL without this word at end?
Thank you for your time

In your .htaccess file:
RewriteEngine on
RewriteRule ^(.*)/YourDribble$ http://Some-True-URL/$1 [R=301,L]

Related

Wordpress : redirect all .pdf to one page

Following migration to a wordpress I would like all the old addresses www.mondomaine.fr/pages/files/PDF/*.pdf towards www.mondomaine.fr/catalogue
I tried with several syntaxes of REDIRECT but it adds the name of the pdf file in the new URL so I end up with a 404
Thank you!
RewriteRule ^pages/files/PDF/([A-Za-z0-9-]+).pdf /catalogue [L,R=301]

Mod rewrite to redirect to 404 if filename is followed by other characters

On my website I have files index.php,home.php,about.php
And The full url is
http://example.com/about.php
and the wired thing is that
http://example.com/about.php#foobar
also goes to the about page . I want to block anything after my files name and redirect it to 404.
I copied this from a similar post :
Rewriterule ([a-zA-Z]+).([a-zA-Z]+) - [L]
Rewriterule ([a-zA-Z]+).([a-zA-Z]+) - [R=404,L]
Its not working. can you help me please?
Edit: its not a hashmark related question.
I want to redirect 404 a url with a trailing path.
I think you are looking for this :
AcceptPathInfo Off
Source : http://httpd.apache.org/docs/2.2/mod/core.html#AcceptPathInfo

htaccess URL rewrite issue - permalinks

I am having some issues trying to prettify some URL's. Basically I need to make this URL http://domain.com/actualfolder/fakepath/this-is-the-article.php to display content from this page http://domain.com/actualfolder/articlemanager.php.
The articlemanager.php is setup to receive a GET url variable in the way of the "this-is-the-article" and search for it in the database. If found, it will display content specific to that result. This part works.
The part that i can't make it to work is the htaccess rule.
This is my rule but it returns 404 not found or 500 if i don't use the initial slashes.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^fakepath/([^/.]+).php$ articlemanager.php?permalink=$1 [L]
I could really use some help, so any suggestion is welcome.
EDIT: the htaccess file lies in the domain.com/actualfolder/ location

forcibly redirect to correct folder

I am new in htaccess.
I updated some SEO pages in my live site after one day some Url changes came so i changed the url again. but google already indexed it. So i want if some one found old url it will redirect to new url But in case of SEO pages only not for other pages.It means it wont affect to any other place.and there are not one page(it is 40-50 pages) can anybody give answer through htaccess or cakephp.
Old Url-
www.testenergy.com/test-energy-reviews
new url-
www.testenergy.com/s/test-energy-reviews
And there are also four senario-
www.testenergy.com/test-energy-reviews
www.testenergy.com/Test-Energy-Reviews
www.testenergy.com/s/test-energy-reviews
www.testenergy.com/s/Test-Energy-Reviews
All these four links will redirect to www.testenergy.com/s/test-energy-reviews Url only
Assuming you have mod_rewrite rules somewhere, you probably want to stick to mod_rewrite. You'll need to add these to the htaccess file in your document root, preferably above any other rules that are there:
RewriteEngine On
RewriteRule ^/?test-energy-reviews$ /s/test-energy-reviews [L,NC,R=301]
RewriteRule ^/?s/Test-Energy-Reviews$ /s/test-energy-reviews [L,R=301]
The NC flag ignores case, so it covers both /test-energy-reviews and /Test-Energy-Reviews. The second rule takes care of /s/Test-Energy-Reviews
I'm not sure why /s/test-energy-reviews (3rd one) is one of your scenarios, since it is exactly what you want to redirect to.
Try This ..!!
Router::redirect('/test-energy-reviews', 'http://www.testenergy.energy/s/test-energy-reviews');
write this line in Controller.
/********* Redirect Url fo small letter if some one type in uppercase in url bar****/
preg_match( '/[A-Z]+/',$this->params->url, $upper_case_found );
if(count($upper_case_found)) {
// Now redirect to lower case version of url
header("HTTP/1.1 301 Moved Permanently");
header("Location: " . ROOTPATH.strtolower($this->params->url) );die();
}
/**** End Code******/
OR in htaccess write following code:
RewriteEngine On
RewriteRule ^/?test-energy-reviews$ /s/test-energy-reviews [L,NC,R=301]

URL search path redirect with .htaccess

can you please help, I'm trying to redirect search results from one URL path to another. The original path is
http://www.dominio.com/?s=searchquery
And I want search results to show here:
http://www.dominio.com/search/searchquery
I have tried many 301 redirects but I don't get it to work, can you help?
Thanks!
Sandra
You can use this code in .htaccess file.
RewriteEngine on
RewriteRule ^search/searchquery.html$ index.php?s=searchquery

Resources