I recently tore down my full Drupal site and rebuilt the whole thing in my own framework from scratch. The site is great. But, the problem is when you type a search in google for images. When you click on an image for my site, instead of landing on the right page, it redirects to the home page. Every URL is exactly the same / same content. The only differece in the .htaccess is:
My site:
Options +FollowSymLinks
RewriteEngine On
# GoDaddy Requires -MultiViews
Options -Multiviews
RewriteBase /
RewriteRule ^([a-zA-Z0-9-]+/?)$ $1.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9-]+) index.php?page=$1 [NC]
Old Drupal Site:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
It's really frustrating. Right now it's about 700 unique visitors a day and 500 of those land on the home page when about 80% percent of them were supposed to land on a different page from a google searched image. Any ideas why this is happening?
-- I don't think the reason is because it was directing to /node/59(Nodes instead of specified paths). I had clean urls enabled and it's redirecting to the home page for every searched image which is a lot.
Your .htaccess looks fine, I don't think that it has anything to do with it.
What you're looking for is some sort of script in that site that is checking for an "valid" referrer, or I'm suspecting that your loading some Javascript to to the following thing:
if (top.location != location) {
top.location.href = document.location.href ;
}
Remove it. It's frame busting code, and has been an (awful) practice for many years in webdevelopment, but it doesn't serve any purpose.
You might try uncommenting and changing the following line in your sites/default/settings.php file.
# $base_url = 'http://www.example.com'; // NO trailing slash!
This has solved problems that I've had when moving a site from my local development site to a remote production site.
Good Luck!
Related
I'm trying to write a simple blog which is working fine untill i get to the pretty links thing.
what i'm looking to do is use URLs like mysite.com/blog/this_post and pass that into the index.html file as a url parameter so index.html?blog=this_post
Been searching everywhere and found a bunch of htaccess code but most didn't work. I did find one solution that tries to work but for some reason isn't doing it correctly. (with and without the Options +FollowSymLinks part)
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^blog/(.*) /blog/index.html?blog=$1
when I use this i get /blog/index.html?blog=index.html in the url instead of keeping the /blog/this_post and porting that into the index.html as expected. Could something on the server be set incorrectly? everything else with the blog is working like a charm but so nothing wrong with the script its just getting the pretty links to work.
Looked at an older site that has wordpress and coppied over that htaccess code but it does that same thing. All the other searches on here and other sites point to the same solution above or the wordpress but for some reason it's passing index.html to the script and not the last url segment "this_post" as expected.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.html [L]
</IfModule>
# END WordPress
what should happen is the user types in
mysite.com/blog/this_post
which remains in the address bar correct? but the htaccess file pulls this_post and passes it as an argument to the index.html script. which is what the examples above should do. why it's changing the address bar to
mysite.com/blog/index.html?blog=index.html
i'm not sure why
side note, since i got this before...yes i'm aware of using the .php extention but .html is a client ask that they're not budging on.
edit-the link for possible duplicate was one I already found and tried to get the current RewriteRule but it's still not working.
The best way is to made something simple like this:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^/]*)\.html$ index.php?blog=$1 [L]
Options -MultiViews
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
then you can do URL like:
mysite.com/this_post
what is equal to:
mysite.com/index.php?blog=this_post
Like that you can do both calls and will work fine.
Generaly you need first decide how you want your SEO URL to look like and then you need to setup .htaccess regex and rules.
NOTE: you can't use .html for GET calls. You can use .php files for your works and use $_GET['blog'] to pickup your data from URL.
Seem to have found the combo that works, the [NC, L] flag combo keeps giving me a crash error so i left it just [NC]. Having it in the root account directory seems to not work also so i moved into the web directory (public_html) and that works for now.
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^blog/(.*) /blog/index.html?blog=$1 [NC]
Still not sure why the L flag gives me a server crash on the pages or why having it in the root doesn't work but moving it up into the public_html folder does, is it possibly a server configuration problem that i'm overlooking?
I have a website that is being redirected from a .co.uk site to a .com site and from a .com back to the .co.uk site causing a redirect loop (ERR_TOO_MANY_REDIRECTS shows up).
The strange thing is that this site was working fine for months when this issue just popped up out of no where. When I did a "git status" to see which files have been changed there where 1000s of files deleted and modified. Here is a screen shot showing some of these files updated (I most certainly didn't update them)
Any idea what might have caused this issue? Here is what the .htaccess file looks like:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
If you have backup of old version then just upload again old files which updated on site.
but these are just pdf files updates I don't think they are causing problem.
I have a serious problem with the links when using https. My knowledge with using https is poor. Although following are the processes that i've done so far.
Scenario:
I have a site that uses HTTPS. ( Certified )
I need only one CheckOut page to load in https where the checkout page is related to sub-domain. ex. member.mydomain.com
Site is in WordPress
Not using WooCommerce !!
Results:
Using htaccess i managed to redirect that certain page ie. Checkout page in https and it works.
ex. https://member.mydomain.com/checkout
However, The Problem:
The problem is that all links are dead links in the checkout page due to which it messes up the whole site. The CSS, JS files all are being loaded in https.
What i have tried so far !!
I tried updating the general settings url to https. So, it works but the same issue to all pages. All the links are broken.
Followed the instructions on this post https://wordpress.stackexchange.com/questions/75921/ssl-breaks-wordpress-css
Also, in this https://managewp.com/wordpress-ssl-settings-and-how-to-resolve-mixed-content-warnings
But the above did not seem to do the trick. I still have the broken links. What am i missing here? Please suggest.
Thank you
Found the solution finally.. Tried modifying the htaccess file again.
Following is what i added in my htaccess in order to fix the problem. It might be useful to someone in the future.
<IfModule mod_rewrite.c>
#-------------------SUB.DOMAIN.COM---------------------
RewriteCond %{HTTP_HOST} ^subdomain.domain.com
RewriteCond %{DOCUMENT_ROOT}/members%{REQUEST_URI} -f
RewriteRule . %{DOCUMENT_ROOT}/members%{REQUEST_URI} [L]
RewriteCond %{HTTP_HOST} ^ subdomain.domain.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . subdirectory/index.php [L]
#-----------------SUB.DOMAIN.COM---------------------
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
This solved the subdomain issue and the 500 error requests as well as the broken links problem.
I want to redirect domainA.com/folder/ which originates within an older wordpress installtion to domainB.com/folder1/folder2/ which is the link to the page within my new wordpress installation wihtout the url changing.
I have managed to achieve this with the .htaccess file inside domainA.com/folder/ which reads:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/folder
RewriteRule ^(.*)$ http://www.domainB.com/folder1/folder2/ [P]
The Rewriterule [P] (proxy) flag does what I want and redirects the page without changing the url but some of the content within my Enfold WP template such as the advanced layer slider and icons fail to load.
I assume this error is due to some sort of conflict with WP's native htaccess code and I also suspect it has to do with the lines:
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
I have experimented with adding the first, third and fourth lines to my code but it doesnt work. Does anybody know how I could resolve this issue?
If it makes any difference the wordpress site I want to direct to (domainB.com/folder1/folder2/) is one whithin a Wordpress Network.
For the moment I have changed the [P] flag to [L] flag which redirects and works but changes the url.
Any help or advice would be much appreciated. Thank you!
Try to change the paths of images (the URLs) in advanced layer slider and icons URLs from
relative to absolute ones (as described in RFC 2396), then you can use the [P] flag in .htaccess again.
Often plugins uses relative paths when outputting content, but this can cause such type of troubles.
This following code takes care of permalinks in WorPress and it is recommended to keep the beginning and ending WordPress lines so that WordPress is able to locate it and modify it as needed. You may already have all this and are just not displaying it. I do not know.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
In the other section you probably need to remove the trailing / after folder2 like so:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/folder
RewriteRule ^(.*)$ http://www.domainB.com/folder1/folder2 [P]
I succeeded in making .htaccess rewrite URLs so I can link to pages without having to define the extension. But, only one of the pages won't work.
The page is called 'games.php' and I link to it through Go to Games!
But whenever I go to it, it goes to '/games/', as if it were a folder, and then gives an Error 404.
I don't know how to fix it. I checked, there's no folder or any other file called like this, and it works on all the other pages... (also on games?id=blabla...)
Here's my .htaccess code:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC]
Thanks in advance,
Dalionzo :D
RewriteEngine On
RewriteBase /
RewriteRule ^games(.*)?$ games.php$1 [L,QSA]
RewriteRule ^games(/)?$ games.php [L,QSA]
UPDATED
Now it works without parameters too.
website.com/game.php?id=blablabla --> website.com/game?id=blablabla