Path issue in wordpress blog - wordpress

We are having some issue with our relative path in wordpress.
Earlier our application was like http://www.skill-guru.com/skill .
So if we type the blog address as http://www.skill-guru.com/blog it would add a / at end and open it as
http://www.skill-guru.com/blog/
Now our application opens as root in domain http://www.skill-guru.com.
Our blog is opening as http://www.skill-guru.com/blog/ but not as http://www.skill-guru.com/blog.
I am not able to understand the reason.
because of this issue , search is also not working.
Can anyone please help me understand what has changed and how it can be fixed ?

I'm not sure about the underlying cause, but while you figure that out you may just want to redirect "blog" to "blog/" in your .htaccess file. I think this will do it...
RewriteCond %{REQUEST_URI} ^.*/blog$
RewriteRule ^(.+)$ $1/ [R=301,L]
I'm assuming that somewhere else in the .htaccess you have...
RewriteEngine On
RewriteBase /
In fact, you might find that in the process of changing you site someone nuked the existing .htaccess.

If I visit http://www.skill-guru.com/blog, I get the error:
HTTP Status 404 - /blog
type Status report
message /blog
description The requested resource
(/blog) is not available. Apache
Tomcat/6.0.16
This implies that there might be url-rewriting in place or server configuration does not allow you to strip the trailing backslash, you should consult with server support theam.

Related

Can not log in to Drupal 7 admin after changing to HTTPS. Access Denied and cookie not set

I can no longer log into Drupal 7's admin area after adding SSL certificate and forcing HTTPS in url.
The website was previously served via HTTP protocol and worked perfectly fine. I would also like to mention that if I revert back to HTTP mode, the site will work as expected. However, I am trying to implement HTTPS.
Additionally, while logging in, I have noticed that the cookie response would be sent by the server but it would get deleted immediately leading to access denied message.
So far, after going through mixed response in the internet, I have played around with session.cookie, $base_url and $cookie_domain variables within settings.php file. I haven't found a solution yet.
Has anyone bumped into this problem? Your response will be highly appreciated.
In apache server
Go to .httaccess
Add # in front of RewriteRule ^ - [E=protossl] to disable http
It looks like this # RewriteRule ^ - [E=protossl]
This solves the problem
Ok so this is a fairly old post but here is what happened with my site.
We installed a new SSL certificate and somehow the .htaccess file ended up empty, and I do mean 100% blank.
This means easy fix, download latest drupal core and just replace the .htaccess file along with the core files, usually you want skip this to preserve all additional code added for html compression and such, but in this case that is redundant.
After the .htaccess was replaced I then added the compression and rerouting code like before and problem solved.
Hope this helps someone else out, I know I will always be checking the .htaccess files first if it happens again.
Disable in .httaccess
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com*
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]

HTTPS on dev server - issues

I copied a live woocommerce site back to the dev server. The live site uses https. So when I tried accessing it on the dev server, it redirected me to the live site. I figured the issue was the .htaccess file. I tried editing it, but the file is encrypted. So I just removed it all together. That stopped the redirecting, and I was able to access the front-end of the dev site. However when I try to access the wp-admin or wp-login.php I get a 404. I also noticed that the broswer changed from http to https. So there's something still trying to make the website run under https.
What I've tried:
I deactivated woocommerce plugin (by renaming it) but that didn't
help.
I also searched in the database for instances of https:// but I
could not find any that related to the website.
I also found and removed a cert.html file in the root which I think
it's related to the https certification, but I still can't access
the backend.
And last, I tried to add a new .htaccess file with the basic
wordpress permalinks in it, but that just gave 500 server errors.
Can anyone give some pointers where to look? Or what could be causing the browser to use https, instead of http.
It looks like you need to change your site URL to point to the right place. Since you can't log in (it'll redirect you to the wrong site URL), you need to change this in your wp-config.php file (see this link for more info):
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
After that, and hopefully with the default wordpress rules, you should be able to log in to the admin pages.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
The above assumes that your wordpress site is at /.

Limit web folder access to specific URL

I am hosting two different websites using one hosting package.
My initial website is self-built and runs from the public_html directory of my host let's call this 'http://www.website1.co.uk'
I also have a Word Press blog running in a folder under the public_html - so '/folder_2', let's call this 'http://www.website2.co.uk' - this URL currently points to '/folder_2' and will load the blog when entered in to a browser.
At the moment the blog is also accessible by entering 'http://www.website1.co.uk/folder_2/'.
I would like to be able to limit access to 'folder_2' to just 'website2.co.uk' - preventing somebody typing in the 'website1.co.uk/folder_2' path and being able to view the blog.
What's the best way to achieve this, bearing in mind the folder in question is running a Word Press blog.
Try adding this in your .htaccess file in folder_2
RewriteEngine On
RewriteCond %{http_host} !website2.co.uk
RewriteRule .* http://website2.co.uk
that would redirect anyone who goes to website1.co.uk/folder_2 to website2.co.uk, but if you just want them hit a 404 put this in .htaccess instead
RewriteEngine On
RewriteCond %{http_host} !website2.co.uk
RewriteRule .* - [R=404,L]
1# move folder_2 out of public_html(you really should do that).
2# rewrite all request of 'http://www.website1.co.uk/folder_2/' to 404 in htaccess
Check below link:
Redirection Subfolder Htaccess

How do I create a redirect from a subdirectory to the root domain?

I am trying to redirect all requests to domain.com/drupal to domain.com, including all sub directories in /drupal.
I have seen several answers telling me how to accomplish the opposite of this with .htaccess, but nothing to go this way. I have tried the following line in .htaccess-
RewriteRule /drupal/* ^/(.*)
as well as several variations of the above, based on those answers, but haven't had any luck.
Thanks!
Try this line:
RewriteRule /drupal/(.*) /$1 [QSA,L]
Let me get this straight ... You have an installation of Drupal in <DocumentRoot>/drupal/. You do not want to alter the drupal installation directory, nor you want to change DocumentRoot in your webserver config. You want to redirect any request, for example /foobar.php, into the drupal directory, resulting in maybe /drupal/foobar.php. And all that without exposing the whole stuff to the user. Right so far? OK, I can only assume that you have an Apache webserver, else .htaccess would not work...
First, make sure that you actually are allowed to use .htaccess, so check on the relevant AllowOverride directive in your apache config.
Then try it this way in your <DocumentRoot>/.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/drupal.*
RewriteRule ^/(.*)$ /drupal/$1 [P]
RewriteCond ensures that you do not run into an infinite loop. The first part of the RewriteRule is always the URL requested by the client. We prefix the part matched inside the parentheses with /drupal/ and force it to be a proxy request via [P] so that apache would only do an internal redirect (instead of sending the client a "Document has moved" redirection code).
BTW: I did not test it. I may have typos in the code. Read http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule for more information.

Modifying CakePHP-resident Wordpress Redirects using mod_rewrite

I have a CakePHP site that contains a vanilla Wordpress installation. It lives in /app/webroot/blog/. The problem I'm having is a strange one.
I have the site configured, through mod rewrite, to redirect all requests to /app/webroot/blog to /blog/. The reason for this is that Wordpress was either throwing errors or displaying no content when the user visited it via the app/webroot path and it works just fine if you visit it at /blog/. It would also redirect the user to /app/webroot/blog if they attempted to visit /blog without a trailing slash, so we added that as well. Here are the mod_rewrite rules we're using to accomplish this:
RewriteRule ^blog$ blog/ [L]
RewriteRule ^app/webroot/blog/(.*)$ blog/$1 [L]
When the user attempts to visit the admin section of Wordpress but is not authenticated, it sends them to the /wp-login.php page and sends along a query string parameter called redirect_to that contains the URL the user was originally trying to access before being asked to authenticate. This URL contains the full path (/app/webroot/blog/...) instead of just going to /blog, even if the original request was a page within /blog. If the user successfully authenticates, then the user is sent back to the login page as though nothing happened (no error messages, etc.).
I would assume that the second mod_rewrite rule listed above would rectify the issue, but it doesn't seem to be.
I hope I've explained this thoroughly, please let me know if I can provide additional information that I may have forgotten. Thanks!
have you tried checking wordpress options in wp database. there are two options you should make sure that are correct. siteurl and home. both should be http://yoursite.com/blog
What's your document root directory? Make app/webroot/ your document root directory and you won't need any additional rewrite rules, because CakePHP's default rewrite rules already have rules for existing files and directories:
So your /app/webroot/index.php will be you application entry point with address .../ ,
and app/webroot/blog/ will be wordpress entry point with address .../blog/
Default rewrite rules are enough for this configuration:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d # this will go to your blog dir, if it exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] # this is CakePHP app

Resources