Home › Forums › BulletProof Security Pro › Adding .html to pages created by plugin with new base name like /portal
- This topic has 42 replies, 2 voices, and was last updated 11 years, 3 months ago by
AITpro Admin.
-
AuthorPosts
-
AITpro Admin
KeymasterThese are 2 great websites for Regex.
http://www.regular-expressions.info/
http://gskinner.com/RegExr/Apache .htaccess code
http://stackoverflow.com/questions/12064504/what-language-are-apache-htaccess-files-written-in
http://httpd.apache.org/docs/2.2/howto/htaccess.htmlYes, the syntax is correct. More about what the back reference $1 means
http://forum.ait-pro.com/forums/topic/htaccess-redirect-code-where-do-i-add-redirect-htaccess-code/Andre
ParticipantCool, thanks. Already learning
Andre
ParticipantAnd I can rule like this:
RedirectMatchMatch 301 ^/component/ http://www.web-assembler.com
Which would mean, it starts with ^ and wont end to redirect, so it would redirect anything behind /component/
Is this line before with the caret cleaner than:
RedirectMatchMatch 301 /component/ http://www.web-assembler.com
without the caret?
AITpro Admin
Keymastercarets and the end $ is technically correct and you should use them. You can of course not use them. That is up to you. (.*) means match anything so you can have an url like this
^/component/(.*)$
I try to use them at all times.
# Redirects a URL starting out with numbers 0-9 and this is a range {2,5} which means match a range of 2 to 5 numbers # example 12, 201, 4352, 10300 would all match the range, but a single number like 4 or numbers over 5 number characters like 209467 (6 number characters) would not match the range. # this URL would be redirected - /45/website-security-842/ to /wordpress-testing-website/category/website-security-testing/ RedirectMatch 301 ^/wordpress-testing-website/[0-9]{2,5}/website-security-[0-9]{2,5}/$ http://www.ait-pro.com/wordpress-testing-website/category/website-security-testing/ # this URL would be redirected - /678/series-4/ to /wordpress-testing-website/category/series-testing/ RedirectMatch 301 ^/wordpress-testing-website/[0-9]{2,5}/series-[0-9]{1,5}/$ http://www.ait-pro.com/wordpress-testing-website/category/series-testing/ RedirectMatch 301 ^/wordpress-testing-website/wordpress-testing-website/author/admin/page/(.*)$ http://www.ait-pro.com/wordpress-testing-website/ RedirectMatch 301 ^/wordpress-testing-website/category/website-security-testing/page/(.*)$ http://www.ait-pro.com/wordpress-testing-website/category/website-security-testing/ RedirectMatch 301 ^/wordpress-testing-website/category/series-testing/page/(.*)$ http://www.ait-pro.com/wordpress-testing-website/category/series-testing/
Andre
ParticipantCool. So: Match anything with (.*) also means text a trailing slash or three folders in a row… right?
So, I can batch rule SOME of the redirects I already have in the htaccess.
Like (what I mean; see in brackets after rule):
^/my-link/(.*)$
(all links I want to batch rule, that were /my-link/ and /my-link/otherlink/ or also /my-link/otherlink.html )^/my-link(.*)$
(the ultimate redirect because ANYTHING is redirected after /my-link , so also /my-link.php or /my-link.html) and in the end I can break it down in higher levels of link structure…Yes?
AITpro Admin
Keymasteryep your are correct (.*) means match everything and anything.
Andre
ParticipantI think my problem wasnt THIS big at the end. I didnt take a general rule to rewrite ALL .html to lead to / links.
I set back the .html hack completely. Then I just switched the link where a dead link is redirected to from an ending with .html to / trailing slash inside the root htaccess custom code.
Think everything is fine now. I watched, that I avoided possible loops because of the images, took out some double rules that got in there “by sudden” 🙂 and also watched rules that might be overriding other rules, like this one:
RedirectMatch 301 ^/online-marketing/(.*)$ http://www.web-assembler.com/online-marketing-direkt-marketing/lokalero-lokales-online-marketing/
…was overriding…
RedirectMatch 301 ^/online-marketing-direkt-marketing/lokalero-lokales-online-marketing.html$ http://www.web-assembler.com/online-marketing-direkt-marketing/lokalero-lokales-online-marketing/
So, it would be useless or contraproductive to keep the first one in… or even giving a huge problem… donno
Thanks for Your gorgeous help on this.
Cheers.
AndreAITpro Admin
KeymasterWhat you may have to do is create unique rules for the scenario you posted above and then you can use overall general rules for other URLs where there will not be issues like this.
Andre
ParticipantHi, regarding another site, where old links should be redirected I took the redirectmatch code but ti doesnt work out anyhow.
See please here:
# Rewrite OLD URLs RedirectMatch 301 ^/new/(.*)$ http://www.johanneshilfswerk.org/
old links are like: johanneshilfswerg.org/new/yaddiyadda
When I search site: johanneshilfswerk and click on /new it redirects to a 404 page… but not to the mainAITpro Admin
KeymasterIf you are redirecting an old folder or category to the root URL then just do this below without using (.*).
RedirectMatch 301 ^/new/$ http://www.johanneshilfswerk.org/
Andre
ParticipantAlso doesnt work. It is a URL from old hosting and old joomla site, doesnt have to do with the current thing. Just the google SERPs shouldnt get lost… https://www.google.de/#q=site:johanneshilfswerk.org
AITpro Admin
KeymasterAre you adding the redirect on the old site? It would have to done from the old site to redirect to the new site because when someone uses the old URL they are sent to the old site and then the old site will redirect them to the new site. If the old site no longer exists then you would just need to create an .htaccess file under that domain.
AITpro Admin
KeymasterExamples:
These are folders where old sites no longer exist, but of course you still would have to own the domains and DNS for these domains would still need to be valid and pointing to these folders/domains.
/old-site.com/subfolder-siteA/
/old-root-site.com/Putting an .htaccess file with redirects in the folders of these old sites that no longer exist will redirect any old URLS to these sites that no longer exist to another site that you are redirecting too.
RedirectMatch 301 ^/subfolder-siteA/$ http://www.new-site.com/ Redirect 301 / http://www.new-site.com/
Andre
ParticipantMmh, kay.
🙂 I think I just didnt understand the system enough. I was coming from the direction, that because the old URL had content system in it (…/new) and the search engine got the URLs still in index that I could make the magic happen from inside the new site (…/htdocs) where WP is installed and running, so that the click on a link in SERPs with …/new in it would be redirected to the new site main page.
But if I got you right, a folder “physically” should exist (cause the domain didnt change at all but the root folder , no /new is there anymore) from where a htaccess could redirect the old links to the main page (or wherever)….
This means, I would now just add
RedirectMatch 301 ^/subfolder-siteA/$ http://www.new-site.com/ Redirect 301 / http://www.new-site.com/
into a new htaccess into the newly created folder “new” in the root of the WP…
Gotcha?
AITpro Admin
KeymasterYes, you are correct. Recreate the /new folder and put an .htaccess file in that folder that redirects to wherever you want it to redirect to.
When Google indexes website pages those URLs are then stored in the Google Database. Google is a gigantic Database that has a search query tool (the Google Search window) that searches that Google Database.
-
AuthorPosts
- You must be logged in to reply to this topic.