Wordpress don't redirect specific url - wordpress

I've created a WP theme, which contains slideshows on different pages. I don't want to use any WP plugins for that specific project, so I tried the following:
define foldes at the root directory (e.g. /slideshow/folder1)
get files from folders on specific pages via php and echo the code
Wordpress naturally redirect any links which are not absolute I guess. This method will work at the home page (because the folders for the slideshow are in the root directory), but not in any other pages.
The schema for the pages is "www.mylocation.com/pagename/". When I'm trying to get the files with a relative url like "../slideshow/folder1" Wordpress redirect the link to "../pagename/slideshow/folder1".
Is there a solution which will work for that specific part (maybe without htaccess redirect)?
The temporarily solution is rewrite the urls after loading via JavaScript but this will force loading failures when php is trying to get the files.

Did you try to set a base URL?
<base href="http://www.mylocation.com/pagename/" />
this may solve the problem.
The tag specifies the base URL/target for all relative URLs in a document.
more details

Related

.htaccess redirect on 404 on specific directory

I'm using wordpress with Avada theme. Every new theme update a new js file is created in /wp-content/uploads/fusion-scripts/
/wp-content/uploads/fusion-scripts/8ca1xxxxxxxxxxxxxxxxxxxa.min.js
/wp-content/uploads/fusion-scripts/d83hhxxxxxxxxxxxxxxxxxxxa.min.js
/wp-content/uploads/fusion-scripts/edij3xxxxxxxxxxxxxxxxxxx.min.js
I cannot control their filenames. Those files are included in the mainpage. Googlebots for example learns those paths and after a theme update it fails because it continues to use the old filenames and gets 404.
I have problems with my security plugin because I'm not able to whitelist /wp-content/uploads/fusion-scripts/ so it is possibile that it bans googlebot.
I would add to my .htaccess something in order to redirect the request to /wp-content/uploads/mytest/a.js which is static and prevent to ban scrapers which uses old cache names
Is it possible?
Riccardo

How to locate index.html / index.php in cPanel

I am editing a wordpress website. My client had a team working on editing it and they simply used the Wordpress editor to make changes. When I log in to cPanel, I see a 'coming soon' page in the index.html file. But the changes that the design team made cannot be located in any file. Also, when I access the website with a http, it shows the website (even when it's not supposed to be launched) and when I access the website with a https, it shows the welcome page. I don't know how two different pages are displayed by just changing the transfer protocol. How do I edit the theme?
If it is a WordPress website, the index file should be under this directory:
/website-root/wp-content/themes/ <- then the theme folder.
The theme, that's active on your website should be mentioned under Appearance > Themes. If you're not sure which one it is in /themes directory, look for the title here.
As you have cPanel, you should have an access to .HTACCESS file for your account. You can set index/default page for your website from .HTACCESS file. Please add the following code:
DirectoryIndex MyFileName.html // Replace MyFileName.html with your actual index file name.
HTTP and HTTPS should show the same contents. Please clear browser cache or verify your website from any alternate system or server.

Putting a custom directory inside wordpress

I have a simple HTML microsite, which I want to put inside my wordpress website. For example: Wordpress website is: abc.com
I want to put my microsite inside this wordpress site. So URL becomes:
abc.com/microsite/
But, wordpress treats any url as its own. How can put "abc.com/microsite/" urls to Wordpress Ignore list. So that any pages inside microsite folder executes independently.
just put you folder 'microsite' in root(Where you find wp-admin,wp-content and wp-include folder). and
you are able to access the folder
"abc.com/microsite/ by this url
If you are still having issues with accessing the subfolder, try renaming the .htaccess to .htaccess-bak in order for WordPress to regenerate the file again. Understand that your website might temporarily go down.
I've found this solution to help in some cases, but I don't know exactly why, ergo I am not sure it will work. And if you feel uncomfortable editing the .htaccess file I suggest you learn more about it (as should I). It is a very powerful file and WordPress uses it a good deal.
P.S. The file is located in the same folder, WordPress' root folder where you find /wp-admin/, /wp-content/, etc. It is hidden by some hosting providers, but I've always been able to find them through FTP with the hosting companies I've used before.

Can Jekyll serve content based on a URL parameter?

I'm migrating a blog from WordPress to GitHub pages. In the logs for my site, I've noticed that there are many requests like this:
GET /wp/?feed=atom
This 301 redirects to the ATOM feed for the site.
I'd planned to use httrack to scrape my site and migrate all the static content. But this presents a problem. Is there any way to replicate the /wp/?foo=bar redirects using Jekyll?
You can use Jekyll redirect_from plugin which is one of the rare plugin that can be used on github pages.
The only problem is that yoursite.github.io/wp/?foo=bar from the server point of view is yoursite.github.io/wp/index.php?foo=bar. So, any ?foo=bar is resolved to the same file.
I you have only your xml feed to redirect, this does the trick :
---
layout: null
redirect_from:
- /wp/
---
content ...
If you have multiple files to redirect, you will have to switch to a javascript solution from a wp/index.html file.

Redirecting old .aspx files to Wordpress equivalents

I've converted an associates old website to Wordpress. The domain name remains the same. All the old .aspx files fall into the root of the domain folder (www.xxx.com) with no .htaccess file while the Wordpress replacement site has an .htaccess file - domain is www.xxx.com/ctpc
I have 36 old .aspx files in the root that I need to permanently redirect to the respective wordpress documents in the /ctpc subfoler.
I can do a little bit of code, html in particular and with good instructions can paste code, but writing code to get this done is obviously over my head.
I've researched this for a day and half now and am going downhill if any direction at all. I'd be grateful for any help possible.
thank you,
~Jennifer
I would recommend putting a .htaccess file in the root domain, with a redirect for each of the 36 .aspx files, like this:
Redirect 301 /oldpage1.aspx http://www.newsite.com/ctpc/newpage
Put one of those on each line for each of the .aspx files. Do this in a text editor, like Notepad for Windows, save it as .htaccess, and then upload it to the root domain.
There's a WordPress redirection plugin that would allow you to manage all of this from within the WordPress admin section. You can create redirects for all of your 36 pages and then keep track of how many time the pages are getting referenced and which pages still have old links.
If you're using permalinks in Wordpress, put the 301 redirect that is listed above the Wordpress rewriting in your .htaccess file. And edit your .htaccess file yourself; if you let Wordpress automatically write to your .htaccess file, sometimes you'll end up with multiple rewrite entries that can cause problems.
Please Use Redirections Plugin
Under Add new redirection, put the following:
Source URL: /(.*).aspx
Regular expression: checked ☑ OR Select "REGEX" after Source URL
Target URL: /$1/
One solution may be to add a META refresh tag to the header section of each of the .ASPX files that you need to redirect.
For example:
<HTML>
<HEAD>
<META http-equiv="refresh" content="5;URL=http://www.xxx.com/ctpc/new-file">
...
This tag says to refresh the page in 5 seconds by sending the user to www.xxx.com/ctpc/new-file. You can make this an immediate refresh by changing the time to 0.

Resources